Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 3.76 KB

SqlServerEventOutbox.md

File metadata and controls

28 lines (19 loc) · 3.76 KB

SQL Server Event Outbox

This is a work in progress...

To enable a consistent implemenation (and re-use) an implementation of the Event Outbox pattern specifically for SQL Server based around the EventSendData as enabled by CoreEx is provided.

The code-generation is enabled by OnRamp leveraging the following templates. The DbEx.Test.OutboxConsole demonstrates usage.

Template Description Example
SchemaEventOutbox_sql.hbs Outbox database schema. See example.
TableEventOutbox_sql.hbs Event outbox table. See example.
TableEventOutboxData_sql.hbs Event outbox table. See example.
UdtEventOutbox_sql.hbs Event outbox user-defined table type. See example.
SpEventOutboxEnqueue_sql.hbs Event outbox enqueue stored procedure. See example.
SpEventOutboxDequeue_sql.hbs Event outbox dequeue stored procedure. See example.
EventOutboxEnqueue_cs.hbs Event outbox enqueue (.NET C#); inherits capabilities from EventOutboxEnqueueBase. See example.
EventOutboxEnqueue_cs.hbs Event outbox dequeue (.NET C#); inherits capabilities from EventOutboxDequeueBase. See example.

Event Outbox Enqueue

The EventOutboxDequeueBase provides the base IEventSender send/enqueue capabilities.

By default the events are first sent/enqueued to the datatbase outbox, then a secondary out-of-process dequeues and sends. This can however introduce unwanted latency depending on the frequency in which the secondary process performs the dequeue and send, as this is essentially a polling-based operation. To improve (minimize) latency, the primary IEventSender can be specified using the SetPrimaryEventSender method. This will then be used to send the events immediately, and where successful, they will be audited in the database as dequeued event(s); versus on error (as a backup), where they will be enqueued for the out-of-process dequeue and send (as per default).