The Outbox feature requires persistence in order to store messages and enable deduplication.
To keep track of duplicate messages, the RavenDB implementation of Outbox creates a special collection of documents called
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);