Last Updated: Dec 03, 2012 08:24PM IST
NserviceBus中有很多特征都要求信息的持久化,主要是timeouts,Sagas,以及subscription的存储。
NserviceBus中有四种持久化技术:
1. RavenDB
2. NHibernate
3. In Memory
4. MSMQ
关于RavenDB的安装可以看 here and怎么样连接到RavenDB参见 here.
Using NHibernate for persistence
NserviceBus3.0开始支持NHibernate持久化技术,其位于单独的程序集中,更多信息参加 Readmore
What's available?
下表总结了哪些是可以获得的,以及如何配置他们:
| InMemory | RavenDB | MSMQ | |
Timeout | √ | √ | √ | Not supported begining version 3.3,0 |
Subscription | √ | √ | √ | √ |
Saga | √ | √ | √ |
|
Gateway | √ | √ | √ |
|
Distributor |
|
| √ | √ |
Second Level Retry |
|
|
| √ |
Fault Management | √ |
|
| √ |
Notifications |
|
|
| √ |
假如self hosting,那么你可以根据你的需求任意配置持久化技术,举一个例子,假如你想要存储subscription在内存中,timeouts在RavenDB中,那么可以使用以下代码:
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());
}
当使用NServiceBus.Host.exe,有现成的profile你可以利用,下表展示了每种预建profile的默认配置采用的是何种持久化技术。 此外,你可以覆盖这些默认的配置,如何覆盖参考
下表总结了应用在内建的profile中的不同的持久化技术,不过在配置一个持久化技术之前首先检查一下是否有别的存储被使用,以避免覆盖了用户的配置。
| 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将会激活Timeout manager,这个角色并不明确决定使用哪种持久化技术,默认的timeout manager的持久化技术是RavenDB。
类似于AsA_Server这个角色,不同的profile将会激活不同的NServiceBus特征,而不需要明确地配置持久化技术,更多的关于各种profile的资料参考 here.