在NSB 5中,如何使用autofac容器正确配置NSB,其中一个IDocumentStore用于NSB数据,另一个IDocumentStore用于应用程序数据?我在下面粘贴了EndpointConfig的相关部分:
// Raven DataStore for Freight system
var appDataStore = new DocumentStore {
ConnectionStringName = "RavenDB",
DefaultDatabase = "ApplicationData"
};
appDataStore .Initialize();
// Raven DataStore for NServiceBus
var nsbDataStore = new DocumentStore
{
ConnectionStringName = "NServiceBus.Persistence",
DefaultDatabase = "BookingProcessing"
};
nsbDataStore.Initialize();
// Set up and build AutoFac container
var builder = new ContainerBuilder();
builder.RegisterInstance<DocumentStore>(appDataStore ).As<IDocumentStore>().SingleInstance();
var container = builder.Build();
// Set up NServiceBus
configuration.UseContainer<AutofacBuilder>(customizations => customizations.ExistingLifetimeScope(container));
configuration.UsePersistence<RavenDBPersistence>().SetDefaultDocumentStore(nsbDataStore);
我知道这不起作用,因为我在another question中存储传奇有问题。 SagaPersister尝试在appDataStore中保留saga,但是超时消息在nsbDataStore中持久存在。
答案 0 :(得分:2)
答案 1 :(得分:1)
这是sample for 4.x using unit of work, 如果你使用
查看here以了解如何实施IManageUnitsOfWork
Init是here 看here for the usage
这会有帮助吗?