Class: OutboxDispatcher
Defined in: src/outbox/OutboxDispatcher.ts:32
Enterprise Transactional Outbox Engine for EntityTS. Guarantees zero message loss and at-least-once delivery between local database transactions and distributed message brokers (e.g. Kafka, RabbitMQ, SQS, Webhooks).
Constructors
Constructor
new OutboxDispatcher(
adapter):OutboxDispatcher
Defined in: src/outbox/OutboxDispatcher.ts:35
Parameters
| Parameter | Type |
|---|---|
adapter | IDbAdapter |
Returns
OutboxDispatcher
Methods
ensureSchema()
ensureSchema():
Promise<void>
Defined in: src/outbox/OutboxDispatcher.ts:37
Returns
Promise<void>
enqueue()
enqueue<
T>(eventType,payload,transaction?):Promise<string>
Defined in: src/outbox/OutboxDispatcher.ts:117
Enqueues a message into the outbox within the current database transaction. If the transaction commits, the message is guaranteed to be saved; if rolled back, nothing is emitted.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
eventType | string | Domain event type name (e.g. 'PAYMENT_RECEIVED', 'ORDER_CREATED'). |
payload | T | Arbitrary event data object or primitive. |
transaction? | DbTransaction | Optional active DbTransaction instance. |
Returns
Promise<string>
Generated outbox message ID.
dispatchPending()
dispatchPending(
handler,options?):Promise<DispatchSummary>
Defined in: src/outbox/OutboxDispatcher.ts:160
Polls and dispatches pending outbox events through the provided delivery handler (e.g. Kafka producer). Updates message status to DISPATCHED or increments retry count on failure.
Parameters
| Parameter | Type | Description |
|---|---|---|
handler | (message) => Promise<void> | Asynchronous message sender callback. |
options? | DispatchOptions | Batch size and max retry attempts. |
Returns
Promise<DispatchSummary>
getPendingCount()
getPendingCount():
Promise<number>
Defined in: src/outbox/OutboxDispatcher.ts:240
Retrieves current pending message count in the outbox.
Returns
Promise<number>