For the complete documentation index, see llms.txt. This section of documentation is indexed by https://docs.particular.net/nservicebus/llms.txt. Here is the markdown version of this page. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md.

RavenDB Gateway Storage

Target Version:
NServiceBus 8.x
Standard support for version 8.x of NServiceBus has expired. For more information see our Support Policy.

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.

List of Samples