Event brokers
Send your organization's factory events to your own Kafka, Amazon SQS, AMQP or NATS broker.
CodeBook can send the events of your organization's factories to a message broker you run: Kafka, Amazon SQS, an AMQP 0-9-1 broker such as RabbitMQ, or NATS. A broker is set up once for the organization and is off until you switch it on.
This is separate from a factory's signed webhooks, described in Events and outcome reporting. Both can be used at the same time.
Add a broker
You need to be an owner or admin of the organization. Other members cannot see this page.
- Open Organization settings → Event broker.
- Choose Add a broker, give it a name and pick the Broker type.
- Fill in the connection: Host, Port and the topic (Kafka), exchange (AMQP) or subject prefix (NATS); Queue URL and Region for SQS. AMQP also takes a Virtual host and a Routing key, which can contain
{kind}for the event kind. On NATS each event goes to the subject prefix followed by the event kind. Choose Use TLS when the broker requires it; the certificate must match the host name. - Choose a Sign-in method and enter the credentials, if the broker needs them.
- Under Events, keep every kind or choose the kinds you want. Under Factories, keep every factory of the organization or choose some. "Every" includes kinds and factories added later.
- Save, then choose Send a test event. The test event is sent straight to the broker and is not recorded as a delivery.
- Switch the broker on.
An organization can have up to five brokers. Passwords, tokens and AWS secret keys are stored encrypted. They are never shown again, logged or included in an error message. To change one, enter a new value.
Switching a broker on starts from the newest event. Earlier events are not sent. Switching it off closes what was still waiting.
What a message looks like
Each event is a CloudEvents 1.0 JSON document:
idiscodebook-event-<event id>. It is the same on every retry, so your consumer can drop repeats.typeiswork.codebook.<kind>, for examplework.codebook.card.moved.sourcenames the factory, andsubjectnames the card when there is one.dataholds the same event body a signed webhook carries, plus the factory, workflow and card ids.
The event id is also sent where each broker expects a message id: Nats-Msg-Id on NATS, message-id on AMQP, the deduplication id on an SQS FIFO queue, and the ce_id header on Kafka. On Kafka the message key is the factory; on an SQS FIFO queue the message group is the factory.
The page shows an example under What a message looks like.
Delivery
Events are sent at least once. A failed send is tried again after 30 seconds, 2 minutes, 10 minutes, 1 hour and 6 hours, and then marked failed. A message the broker refuses for good, such as one that is too large or not permitted, is marked failed at once.
Deliveries lists the newest fifty, with the reason for each failure. Send what failed again queues the last week's failed deliveries once more. A delivery is kept for thirty days after it finished.
If a factory's egress policy does not allow the broker's host, that factory's events are not sent to it. The delivery says so and the refusal is recorded on the factory.
Network rules
CodeBook looks up the broker's address once and refuses private, loopback, link-local and cloud metadata addresses. It then connects to exactly the address it checked. For Kafka this also applies to every partition leader the cluster names. A broker on a private network is not reachable from the hosted app.
Remove a broker
Choose Remove and type the broker's exact name. The server checks the name too. Its delivery history goes with it. Every change to a broker is recorded in the audit trail.
What is supported
| Broker | Sign-in | Notes |
|---|---|---|
| Kafka | None, SASL PLAIN, SCRAM-SHA-256, SCRAM-SHA-512 | Produce only. No compression, no idempotent or transactional producer. |
| Amazon SQS | Access key (Signature V4) | Standard and FIFO queues. No session tokens or instance roles. |
| AMQP 0-9-1 | PLAIN | Publisher confirms. Other sign-in mechanisms are not supported. |
| NATS | None, user and password, token | Can wait for a JetStream stream to store each event. No NKeys or credential files. |
TLS uses the system's trusted certificate authorities; a private certificate authority cannot be added.
These connections were tested against local stand-ins written from each protocol's documentation. They have not yet been run against a hosted Kafka, RabbitMQ, NATS or SQS account. Send a test event and watch Deliveries before relying on a broker.