Getting Started
Architecture
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

RavenDB Gateway Storage

NuGet Package: NServiceBus.Gateway.RavenDB (3.x)
Target Version: NServiceBus 8.x

Provides deduplication storage for the gateway component in RavenDB.

Usage

var gatewayConfiguration = new RavenGatewayDeduplicationConfiguration((builder, _) =>
{
    var documentStore = new DocumentStore
    {
        Urls = new[] { "database-server-url" },
        Database = "default-database-name"
    };

    documentStore.Initialize();

    return documentStore;
})
{
    // When running in a cluster, enable cluster wide transaction support
    EnableClusterWideTransactions = true,
};

var gatewaySettings = endpointConfiguration.Gateway(gatewayConfiguration);

Cleaning up old records

After a certain amount of time, duplicates are no longer likely and deduplication data should be cleaned up. The RavenDB gateway storage component provides a built-in mechanism based on the RavenDB Expiration feature which is activated by default on the database server.

Deduplication data is kept for 7 days by default, and the cleanup job is executed every 10 minutes. To customize the expiration policy use DeduplicationDataTimeToLive and FrequencyToRunDeduplicationDataCleanup, as shown below:

gatewayConfiguration.DeduplicationDataTimeToLive = TimeSpan.FromDays(15);
gatewayConfiguration.FrequencyToRunDeduplicationDataCleanup = 86400;

In this example, deduplication data are preserved for 15 days and cleanup is run every 24 hours.

Samples