Outbox with RavenDB persistence

Component: RavenDB Persistence
NuGet Package NServiceBus.RavenDB (6.4)
Target NServiceBus Version: 7.x
RavenDB's implementation of distributed transactions contains a bug that could cause an endpoint, in certain (rare) conditions, to lose data. If RavenDB is configured to enlist in distributed transactions, read DTC not supported for RavenDB Persistence.

The Outbox feature requires persistence in order to store messages and enable deduplication.

Extra collections created by the RavenDB Outbox persistence

To keep track of duplicate messages, the RavenDB implementation of Outbox creates a special collection of documents called OutboxRecord.

Deduplication record lifespan

The RavenDB implementation by default keeps deduplication records for 7 days and runs the purge every 1 minute.

These default settings can be changed by specifying new defaults in the settings dictionary:

var outbox = endpointConfiguration.EnableOutbox();

Starting with NServiceBus.RavenDB version 6.3, it is recommended to disable cleanup and rely on document expiration instead.

Cleanup may be disabled by specifying Timeout.InfiniteTimeSpan for SetFrequencyToRunDeduplicationDataCleanup:

var outbox = endpointConfiguration.EnableOutbox();

If document expiration cannot be used, to improve efficiency it is advised to run cleanup on only one endpoint instance per RavenDB database, by disabling clean up on all other endpoint instances.

If document expiration is not being used when running in multi-tenant mode, cleanup must be handled manually, since NServiceBus does not know what databases are in use.

Related Articles

  • Outbox
    Reliable messaging without distributed transactions.

Last modified