How to configure NServiceBus with two RavenDB IDocumentStores?

青春壹個敷衍的年華 提交于 2020-01-06 13:51:25

问题


In NSB 5, how do I correctly configure NSB with autofac container with one IDocumentStore for NSB data and a separate IDocumentStore for application data? I've pasted the relevant part of EndpointConfig below:

            // 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);

I know this isn't working since I had problems storing sagas in another question. The SagaPersister tried to persist saga in appDataStore, but the Timeout Messages was persisted in nsbDataStore.


回答1:


This is a sample for 4.x using unit of work, If you use

Look here to see how you can implement IManageUnitsOfWork

The Init is here Look here for the usage

will this help?




回答2:


This issue is now fixed in NServiceBus.RavenDB v2.0.1



来源:https://stackoverflow.com/questions/26798942/how-to-configure-nservicebus-with-two-ravendb-idocumentstores

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!