Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Outbox with RavenDB persistence

In RavenDB 3.5, the client implementation of distributed transactions contains a bug that could cause an endpoint to lose data under rare conditions. If RavenDB is configured to enlist in distributed transactions with RavenDB 3.5, read DTC not supported for RavenDB Persistence.
Using RavenDB version 5 and higher in a cluster configuration with multiple nodes is only supported from version 7 or higher of the NServiceBus.RavenDB persistence package. For more information, read cluster configuration with multiple nodes not supported.

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 persistence retains deduplication records for 7 days by default and runs the cleanup operation every minute.

These settings can be modified by specifying the desired values in the settings dictionary:

var outboxSettings = endpointConfiguration.EnableOutbox();
outboxSettings.SetTimeToKeepDeduplicationData(TimeSpan.FromDays(7));

Starting with NServiceBus.RavenDB version 7.0, cleanup is disabled by default and it is recommended to rely on document expiration instead.

If document expiration cannot be used it is possible to enable the outbox purging by specifying:

var outboxSettings = endpointConfiguration.EnableOutbox();
outboxSettings.SetFrequencyToRunDeduplicationDataCleanup(TimeSpan.FromMinutes(1));

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

var outbox = endpointConfiguration.EnableOutbox();
outbox.SetFrequencyToRunDeduplicationDataCleanup(Timeout.InfiniteTimeSpan);
If document expiration is not used when operating in multi-tenant mode, cleanup must be handled manually, since NServiceBus is unaware of the databases in use.

Related Articles

  • Outbox
    Reliable messaging without distributed transactions.

Last modified