How to configure NServiceBus with two RavenDB IDoc

2019-09-09 22:07发布

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.

2条回答
地球回转人心会变
2楼-- · 2019-09-09 22:36

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?

查看更多
家丑人穷心不美
3楼-- · 2019-09-09 22:46

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

查看更多
登录 后发表回答