Uses the RavenDB document database for storage.
Persistence at a glance
For a description of each feature, see the persistence at a glance legend.
Feature | |
---|---|
Supported storage types | Sagas, Outbox, Subscriptions, Timeouts |
Transactions | via IDocumentSession. |
Concurrency control | Optimistic concurrency, optional custom pessimistic concurrency for performance |
Scripted deployment | Not supported |
Installers | None. Required indexes are created in the database as needed. |
RavenDB versions
Specific versions of RavenDB Persistence are tied to a major version of NServiceBus and also designed to work with a specific version of the RavenDB client library. When releasing a new major version of NServiceBus, the corresponding RavenDB Persistence release will use the last supported version of RavenDB, so that it is never necessary to upgrade both NServiceBus and RavenDB at the same time.
NServiceBus | RavenDB Persistence | RavenDB Client | Platform |
---|---|---|---|
7.x | 6.0.x | 4.2 | .NET 4.7.2 / .NET Core 2.1 |
7.x | 5.0.x | 3.5 | .NET 4.5.2 / .NET Core 2.0 |
6.x | 4.2.x | 3.5 | .NET 4.5.2 |
6.x | 4.0.x | 3.0 | .NET 4.5.2 |
5.x | 3.2.x | 3.5 | .NET 4.5.2 |
5.x | 3.0.x | 3.0 | .NET 4.5.2 |
5.x | 2.x | 2.5 | .NET 4.5.2 |
See the NServiceBus Packages Supported Versions to see the support details for each version of RavenDB Persistence.
Connection options for RavenDB
There are a variety of options for configuring the connection to a RavenDB Server. See RavenDB Connection Options for more details.
Supported clustering configurations
NServiceBus does not support multi-master RavenDB cluster configurations. Only fail-over clustering modes are supported. Consistency cannot be guaranteed in multi-master configurations and NServiceBus cannot do automated conflict resolution for conflicts in multi-master configurations.
Shared session
NServiceBus supports sharing the same RavenDB document session between Saga persistence, Outbox persistence, and business data, so that a single persistence transaction can be used to persist the data for all three concerns atomically. Shared sessions are automatically configured when an endpoint has enabled the Outbox feature or contains sagas.
To use the shared session in a message handler:
Although additional database operations inside a saga handler are not recommended (see warning below) the shared session can also be accessed from a saga handler:
If the situation is special enough to warrant going against this recommendation, the following documentation will describe how to do so.
Customizing the IDocumentSession
IDocumentSession
instance is incompatible with the Outbox feature. Contact support if this poses a problem.The creation of the RavenDB IDocumentSession
instance used by NServiceBus and made available as the shared session can be customized as shown in the following snippet. Despite the name of the method, this option does not enable the shared session but only affects the customization of that session.
var myDocumentStore = new DocumentStore();
// configure documentStore properties here
var persistence = busConfiguration.UsePersistence<RavenDBPersistence>();
persistence.UseSharedSession(
getSessionFunc: headers =>
{
var session = myDocumentStore.OpenSession();
// customize session here
return session;
});
DocumentStore
is created by the user at endpoint configuration time it's important to dispose it, by calling the Dispose()
method, before shutting down the endpoint process.The getSessionFunc
function receives the incoming message headers as an argument. Message headers can be used to support multi-tenant environments customizing the shared session based on the currently processed message.
Saga correlation
One of the limitations of the RavenDB persistence is support for only one [Unique]
property (a saga property which value is guaranteed to be unique across all sagas of this type). Because of that limitation advanced user can turn off the validation that ensures sagas are only being found by unique properties:
var persistence = busConfiguration.UsePersistence<RavenDBPersistence>();
persistence.AllowStaleSagaReads();
Viewing the data
Open a web browser and type the URL of the RavenDB server. This opens the RavenDB Studio.
Migrating timeouts
Timeouts can be migrated to the native-delay delivery implementation with the migration tool.