Various features of NServiceBus require persistence. Among them are timeouts, Sagas and subscription storages.
There are four persistence technologies in use within NServiceBus:
- RavenDB
- NHibernate
- In Memory
- MSMQ
You can read more about installing Raven DB here and how to connect to it, here.
Using NHibernate for persistence
Starting with NServiceBus 3.0 the support for NHibernate persistence is now located in a separate assembly. Read more
What's available?
The following table summarize what's available and how to configure each:
| InMemory | RavenDB | NHibernate | MSMQ | |
| Timeout | √ | √ | √ | Not supported begining version 3.3,0 |
| Subscription | √ | √ | √ | √ |
| Saga | √ | √ | √ | |
| Gateway | √ | √ | √ | |
| Distributor | √ | √ | ||
| Second Level Retry | √ | |||
| Fault Management | √ | √ | ||
| Notifications | √ |
If self hosting then you can configure the persistence technology you would like to use for each feature.
For example, if you want to store subscriptions in memory and timeouts in RavenDB, use the following code:
static void Main() { Configure.With() .Log4Net() .DefaultBuilder() .XmlSerializer() .MsmqTransport() .IsTransactional(true) .PurgeOnStartup(false) .InMemorySubscriptionStorage() .UnicastBus() .ImpersonateSender(false) .LoadMessageHandlers() .UseRavenTimeoutPersister() .CreateBus() .Start(() => Configure.Instance. ForInstallationOn<NServiceBus. Installation.Environments.Windows>().Install()); }
When using NServiceBus.Host.exe, out of the box you can utilize one of the available profiles. The following table shows which persistence technology each pre-built profile is configuring by default. In addition it is possible for you to override the configured defaults. Read more on profiles here and here.
The following table summarize the different persistence technologies being used by the built in Profiles, please note that the profiles, before configuring a persistence technology checks if other storages is used to avoid overriding things configured by the user.
| InMemory | RavenDB | NHibernate | MSMQ | |
| Timeout | Lite | Integration/Production | Keeps a queue for management | |
| Subscription | Lite | Integration/Production | ||
| Saga | Lite | Integration/Production | ||
| Gateway | Lite | MultiSite | ||
| Distributor | Distributor | |||
| Second Level Retry | Uses Timeout queue | |||
| Fault Management | Lite | Integration/Production | ||
| Notifications | Lite/Integration/Production |
Default Persisting Technology
AsA_Server role will activate the Timeout manager. This role, does not explicitly determine which persisting technology to use for that. Hence, the default persisting technology for timeout manager will be used (RavenDB), unless configured differently.
Similar to the AsA_Server role, the various profiles will activates the different NServiceBus features, without explicitly configuring the persisting technology.
Read more about the various profiles here.
