NServiceBus:如何让订阅者在不使用通用主机的情况下开始处理混乱?
我正在修改 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);
现在我想将其更改为没有通用主机的控制台应用程序。以下是我所做的更改:
- 将项目输出更改为控制台应用程序
- 将启动设置更改为不调用通用主机
将上面的配置移至 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);
Console.ReadLine();
我还应该做其他事情来“启动”订阅者来读取消息吗?
I am modifying the PubSub sample, and have been playing around with the configuration of NServiceBus. Currently, my EndpointConfig.cs file has configuration like this:
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);
Now I want to change it to just be a console app without the generic host. Here's what I changed:
- Changed the project output to be Console app
- Changed the startup settings to not invoke the generic host
Moved the configuration above to the Main method like this:
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);
Console.ReadLine();
Is there something else I should be doing to "startup" the subscriber to read messages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看异步页面示例,了解如何自行托管 NServiceBus(就像在 IIS 中一样)。您缺少 .UnicastBus().LoadMessageHandlers().Start()。
Look at the Async Pages sample to see how to self-host NServiceBus (like in IIS). You're missing .UnicastBus().LoadMessageHandlers().Start().
仅供参考,我的配置看起来像这样,
FYI my config looks something like,