Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Outbox with 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 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 outbox = endpointConfiguration.EnableOutbox();
outbox.SetTimeToKeepDeduplicationData(TimeSpan.FromDays(7));
outbox.SetFrequencyToRunDeduplicationDataCleanup(TimeSpan.FromMinutes(1));

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();
outbox.SetFrequencyToRunDeduplicationDataCleanup(Timeout.InfiniteTimeSpan);

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.

Related Articles

  • Outbox
    Ensure message consistency with the NServiceBus Outbox, handling message deduplication and transactional integrity in distributed systems.