gpt4 book ai didi

NServiceBus:如何让订阅者在不使用通用主机的情况下开始处理困惑?

转载 作者:行者123 更新时间:2023-12-02 08:56:43 25 4
gpt4 key购买 nike

我正在修改 PubSub 示例,并且一直在研究 NServiceBus 的配置。目前,我的 EndpointConfig.cs 文件具有如下配置:

Configure.With(new[] { typeof(IEvent), typeof(NServiceBus.Unicast.Transport.CompletionMessage) })
.CustomConfigurationSource(new UserConfigurationSource()
.Register(() => new MsmqTransportConfig { InputQueue = "Subscriber2InputQueue", ErrorQueue = "error", NumberOfWorkerThreads = 1, MaxRetries = 5 }))
.DefaultBuilder()
.XmlSerializer()
.MsmqTransport()
.IsTransactional(true);

现在我想将它更改为只是一个没有通用主机的控制台应用程序。这是我更改的内容:

  1. 将项目输出更改为控制台应用
  2. 将启动设置更改为不调用通用主机
  3. 像这样将上面的配置移动到 Main 方法:

            Configure.With(new[] { typeof(IEvent), typeof(NServiceBus.Unicast.Transport.CompletionMessage) })
    .CustomConfigurationSource(new UserConfigurationSource()
    .Register(() => new MsmqTransportConfig { InputQueue = "Subscriber2InputQueue", ErrorQueue = "error", NumberOfWorkerThreads = 1, MaxRetries = 5 }))
    .DefaultBuilder()
    .XmlSerializer()
    .MsmqTransport()
    .IsTransactional(true);


    <pre><code> Console.ReadLine();
    </code></pre>

我还应该做些什么来“启动”订阅者来阅读消息吗?

最佳答案

查看异步页面示例,了解如何自托管 NServiceBus(就像在 IIS 中一样)。您缺少 .UnicastBus().LoadMessageHandlers().Start()。

关于NServiceBus:如何让订阅者在不使用通用主机的情况下开始处理困惑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4328315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com