如何使用两个 RavenDB IDocumentStore 配置 NServiceBus? [英] How to configure NServiceBus with two RavenDB IDocumentStores?

查看:64
本文介绍了如何使用两个 RavenDB IDocumentStore 配置 NServiceBus?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 NSB 5 中,如何使用 autofac 容器正确配置 NSB,其中一个 IDocumentStore 用于 NSB 数据,另一个 IDocumentStore 用于应用程序数据?我在下面粘贴了 EndpointConfig 的相关部分:

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

我知道这不起作用,因为我在 另一个问题.SagaPersister 试图在 appDataStore 中持久化 saga,但超时消息被持久化在 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.

推荐答案

这是一个示例对于 4.x 使用工作单元,如果你使用

查看此处,了解如何实施IManageUnitsOfWork

Look here to see how you can implement IManageUnitsOfWork

Init 位于此处查看此处的用法

这会有帮助吗?

这篇关于如何使用两个 RavenDB IDocumentStore 配置 NServiceBus?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆