- RabbitMQ direct — bind your own queue to Midaz’s AMQP exchanges.
- Streaming Hub — subscribe through Lerian’s managed fan-out service.
The two approaches at a glance
Midaz publishes domain events over two transports:
- A RabbitMQ (AMQP) publish to topic exchanges that the Midaz deployment owns.
- An internal event bus publish that the Streaming Hub consumes and fans out to per-tenant subscribers.
If you do not operate your own Midaz broker, use the Streaming Hub. Direct RabbitMQ is for integrators who run inside or adjacent to the Midaz deployment and own the broker.
Option A — RabbitMQ direct
How it works
The Midaz ledger publishes events through an internal producer to a set of topic exchanges. A consumer binds its own queue to the relevant exchange with a routing-key pattern. The consumer then reads messages over AMQP. Publisher facts (from the ledger service):- Content type:
application/json - Delivery mode: persistent
- Headers: the producer injects OpenTelemetry trace-context into every message
- Tenancy: the producer is multi-tenant and publishes messages to a tenant-specific vhost
Midaz enables these exchanges by default. Midaz treats each flag as enabled unless you explicitly set it to
false. The bundled example environment configuration ships all three flags set to false. A stack that starts from that example emits nothing until you override the flags.For self-hosted operators
A dedicated environment flag controls each exchange. Midaz treats a flag as enabled unless you explicitly set it tofalse. The bundled example configuration ships all three flags set to false:
On a stack that starts from the example configuration, set the flag to
true in your Midaz deployment configuration. You can also remove the false value instead. This keeps the matching exchange active.
Message shape
Transaction events wrap the domain object in an envelope:midaz.transaction.APPROVED or midaz.balance.overdraft.drawn. You can bind narrowly and avoid a filter in code.
Setup example
Connection parameters come from the Midaz deployment’s RabbitMQ configuration. These includeRABBITMQ_HOST, RABBITMQ_PORT_HOST (the AMQP port used to dial the broker — 3003 in the bundled infrastructure; RABBITMQ_PORT_AMQP is the management port despite its name), a consumer user such as RABBITMQ_CONSUMER_USER, and RABBITMQ_VHOST. In multi-tenant deployments the producer resolves a per-tenant vhost; a single-tenant deployment uses the one static RABBITMQ_VHOST. For TLS, set RABBITMQ_TLS=true in multi-tenant mode, or RABBITMQ_URI=amqps in single-tenant mode.
When to use it
- You operate or co-locate the Midaz deployment and already own the broker.
- You want native AMQP semantics — per-message
ack/nack, prefetch/QoS, dead-letter exchanges you control, competing consumers on one queue. - Your stack is already RabbitMQ-native and you want the lowest-latency, in-cluster hop.
Trade-offs
- Couples you to Midaz’s internal broker topology and credentials.
- The bundled example configuration ships the exchanges disabled. A stack that starts from it needs the operator to re-enable them.
- No managed retry/dead-letter/auto-disable — you own delivery reliability on the consumer side.
- Not viable for a third party that has only network access to a hosted Midaz.
Option B — Streaming Hub
How it works
The Streaming Hub is Lerian’s fan-out delivery edge. It consumes events from Midaz’s internal event bus and delivers each matched event to a per-tenant subscriber sink that you register. You never touch Kafka or the broker. You register a subscription through a REST control plane and choose a delivery method. Supported sink kinds:webhook— the hub POSTs each event to your HTTPS endpoint, HMAC-signed with a per-subscription signing secret.pull— you pollGET /v1/events. The read is the acknowledgment (cursor-as-ack), with no inbound endpoint.sqs,rabbitmq,eventbridge— the hub delivers into your AWS queue, your RabbitMQ broker, or your EventBridge bus.
Events available
Query the catalog to see the event types you can subscribe to:<resource>.<event> (all at schema 1.0.0), including:
organization.*,ledger.*,account.*,asset.*,portfolio.*,segment.*(created/updated/deleted)operation-route.*,transaction-route.*(created/updated/deleted)balance.created,balance.config-changed,balance.deletedbalance.overdraft-drawn,balance.overdraft-repaid,balance.overdraft-clearedtransaction.posted,transaction.committed,transaction.canceled,transaction.reverted
Authentication
The control plane is 100%lib-auth JWT (Bearer) — the hub mints no credential of its own. Present a plugin-auth-issued JWT on every /v1 call:
tenantId, then owner as a fallback), never from the request body. A machine client obtains its token from plugin-auth’s client-credentials flow. It exchanges an application id and secret for a short-lived access token.
Setup example — webhook subscription
201 Created returns the subscription and the signing secret exactly once. Store it immediately. You can rotate the secret later, but you can never read it again:
POST /v1/subscriptions/:id/ping to send a signed synthetic event. This confirms that your endpoint works.
Setup example — pull subscription (serverless-friendly)
Create it with"sink_kind": "pull" (omit endpoint — the server synthesizes one), then poll:
seq returned advances a durable, monotonic cursor. Replay the server-issued next_cursor as ?after= on the next call. Each event carries ceId for your own dedup.
Queue sinks (SQS / RabbitMQ / EventBridge)
You create a queue-kind subscription without a credential, and it starts inpending_verification. It emits nothing until you supply an outbound credential via PUT /v1/subscriptions/:id/credential. The hub probes that credential (connect and auth) and, on success, flips the subscription to active. For a RabbitMQ sink, set endpoint to "<exchange>/<routingKey>". The broker host lives in the encrypted credential. For AWS sinks, fetch the IAM trust policy and ExternalId from GET /v1/subscriptions/:id/setup-artifacts, then wire the cross-account grant before the credential PUT.
When to use it
- You are an external integrator with only network access to a hosted Midaz.
- You want serverless delivery — a webhook endpoint or an HTTP pull loop, no broker to run.
- You want managed reliability — dedup, retry/backoff, dead-lettering, auto-disable, signed webhooks — without building it yourself.
- You want to fan the same events into AWS-native infrastructure (SQS/EventBridge).
Limitations
- No SSE or WebSocket transport — delivery is webhook push or HTTP pull (plus the queue sinks).
- The catalog is global (identical regardless of which tenant authenticates).
- Pull consumers own their cursor position — a forward seek past the cursor permanently skips the gap. Use
?after=to replay from any priorseq.
Decision table
Rule of thumb: if you own the broker and want raw AMQP control, go RabbitMQ direct. In every other case — external integration, serverless, managed reliability, AWS delivery — use the Streaming Hub.
Security considerations
- Least-privilege credentials. For RabbitMQ direct, connect with a consumer-scoped user (not the publisher/default user), restricted to the tenant vhost, and enable TLS (
amqps://). For the Streaming Hub, scope the plugin-auth application to the tenant it represents and rotate the client secret. - Verify webhook signatures. Always validate the HMAC-v1 signature with your per-subscription signing secret before you act on a webhook. Treat an unsigned or mismatched request as hostile.
- Guard the signing secret. The hub shows it once at create or rotate, and never again. Store it in a secrets manager, then rotate it via
POST /v1/subscriptions/:id/secret/rotate(24h dual-sign overlap) if the secret leaks. - HTTPS-only endpoints. Webhook sinks must be
https://. The hub SSRF-validates endpoints at create and at credential PUT, and it rejects plaintext or private targets. - Tenant isolation is claim-derived. The hub reads tenant identity only from validated JWT claims (or
ce-tenantidon ingest), never from the request body, so never sendtenant_idin a payload. - Idempotency & dedup. Send
X-Idempotencyon mutating control-plane calls. On the data plane, dedup onceId(Streaming Hub), the message id, or your own key (RabbitMQ), because both transports are at-least-once. - Don’t expose Midaz internals. Never share the internal balance-operation exchange or broker credentials with external consumers, and front third parties with the Streaming Hub instead.

