NServiceBus:如果不使用通用主机,如何获取对总线的引用

发布于 2024-10-02 19:25:52 字数 251 浏览 1 评论 0原文

我正在尝试创建一组使用 NServiceBus/MSMQ 相互发送消息的服务。我这样做时没有进行任何 XML 配置,而且我现在也不打算使用 NServiceBus 通用主机(带有标记接口、配置文件、容器和其他疯狂配置选项的“黑魔法”太多)。

我想做的就是让我的配置简单明了,并完全包含在“Main()”中,然后能够在循环或其他方式中调用 Bus.Publish() 。除了我不知道如何获得对总线的引用之外,我已经一切正常。

谁能告诉我该怎么做?谢谢! :)

I am trying to create a set of services that send messages to each other using NServiceBus/MSMQ. I am doing so with NO XML configuration whatsoever, and I am also NOT planning on using the NServiceBus generic host for now (too much "black magic" with marker interfaces, profiles, containers and other crazy configuration options).

All I want to do is have my configuration be straightforward, and be completely contained in "Main()" and then be able to call Bus.Publish() in a loop or something. I have got everything working except for I don't know how to get a reference to Bus.

Can anyone tell me how to do that? Thanks! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烏雲後面有陽光 2024-10-09 19:25:52

试试这个:

var bus = NServiceBus.Configure.With()
  .DefaultBuilder()
  .XmlSerializer()
  .MsmqTransport()
  .UnicastBus()
  .CreateBus()
  .Start();

bus.Send(new WhateverMessage());

Try this:

var bus = NServiceBus.Configure.With()
  .DefaultBuilder()
  .XmlSerializer()
  .MsmqTransport()
  .UnicastBus()
  .CreateBus()
  .Start();

bus.Send(new WhateverMessage());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文