Template
Optional
now?: NowFunctionOptional
onOptional
onOptional
partitionOptional
saveUse with consciously and carefully.
When true
, Hermes will be affecting many documents, resulting in much more I/O operations.
Optional
shouldOptional
waitInstance of the database connection.
Instance of the specific database where the OutboxConsumer
will work on.
A callback implemented on the client that is rensposible to publish an event.
It can utilize an event bus like RabbitMQ, Apache Pulsar or whatever is needed.
It takes an event
of Event
.
The most important is to throw an error on a failed publish. Otherwise, the OutboxConsumer
won't consider the event as published.
Name of the partition of the OutboxConsumer
.
Time after the OutboxConsumer
will wait after a failed event publish.
Indicates whether the OutboxConsumer
should register a cleaning callback on SIGTERM
and SIGINT
.
A callback fired on a failed publish.
A callback failed on an error related to the database.
Event - Events handled by the OutboxConsumer
. The type can be limited with a discrimitation union.
const outbox = createOutboxConsumer<Event1 | Event2>({
client,
db: client.db('hospital'),
publish: async (event) => await eventBus.publish(event),
})
Creation parameters of
OutboxConsumer
.