将 NServiceBus 与多个应用程序一起使用,同时充当发布者和订阅者

发布于 2024-09-02 15:44:49 字数 1854 浏览 3 评论 0原文

我正在尝试使用 NServiceBus 使 4 个应用程序一起通信。

所有这些应用程序都必须充当发布者和订阅者。

我创建让它工作的唯一方法是创建一个名为 Server 的“主”队列,在 所有应用程序配置中的 MessageEndpointMappings 都映射到哪个,但我认为这不是好方法...

那么我应该如何在所有这些应用程序上配置 NServiceBus 才能使其正常工作?

应用 1:

  <MsmqTransportConfig InputQueue="MyApp1" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
  <MsmqSubscriptionStorageConfig Queue="Subscriptions" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp.Messages" Endpoint="Server" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

应用 2:

  <MsmqTransportConfig InputQueue="MyApp2" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
  <MsmqSubscriptionStorageConfig Queue="Subscriptions" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp.Messages" Endpoint="Server" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

应用 3:

  <MsmqTransportConfig InputQueue="MyApp3" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
  <MsmqSubscriptionStorageConfig Queue="Subscriptions" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp.Messages" Endpoint="Server" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

应用 4:

  <MsmqTransportConfig InputQueue="MyApp4" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
  <MsmqSubscriptionStorageConfig Queue="Subscriptions" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp.Messages" Endpoint="Server" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

I'm trying to use NServiceBus to make 4 applications communicating together.

All these applications have to act as Publisher and Subscriber.

The only way i founded ti get it workiing is to create a "master" queue named Server, on
which MessageEndpointMappings in all applications configuration is mapped to, but i think it's not the good way ...

So how should i configure NServiceBus on all these application to get this working ?

Application 1 :

  <MsmqTransportConfig InputQueue="MyApp1" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
  <MsmqSubscriptionStorageConfig Queue="Subscriptions" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp.Messages" Endpoint="Server" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

Application 2 :

  <MsmqTransportConfig InputQueue="MyApp2" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
  <MsmqSubscriptionStorageConfig Queue="Subscriptions" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp.Messages" Endpoint="Server" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

Application 3 :

  <MsmqTransportConfig InputQueue="MyApp3" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
  <MsmqSubscriptionStorageConfig Queue="Subscriptions" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp.Messages" Endpoint="Server" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

Application 4 :

  <MsmqTransportConfig InputQueue="MyApp4" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
  <MsmqSubscriptionStorageConfig Queue="Subscriptions" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp.Messages" Endpoint="Server" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

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

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

发布评论

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

评论(1

抹茶夏天i‖ 2024-09-09 15:44:49

NServiceBus 希望您遵循仅由一项服务发布的特定消息类型的模式。通常,每个服务都会有一个“消息”组件,例如:

  <MsmqTransportConfig InputQueue="MyApp1" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
  <MsmqSubscriptionStorageConfig Queue="MyApp1Subscriptions" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp2.Messages" Endpoint="MyApp2" />
      <add Messages="MyApp3.Messages" Endpoint="MyApp3" />
      <add Messages="MyApp4.Messages" Endpoint="MyApp4" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

如果您想从所有四个应用程序发布相同的消息类型,您可以使用 Bus.Send() 将消息发送到中央事件发布者服务,然后中央事件发布者服务可以使用 Bus.Send() 将消息发送到中央事件发布者服务。发布()它。

NServiceBus prefers you follow the pattern of a particular message type being published by one service only. Typically you will have a 'messages' assembly for each service, eg:

  <MsmqTransportConfig InputQueue="MyApp1" ErrorQueue="Errors" NumberOfWorkerThreads="1" MaxRetries="5"/>
  <MsmqSubscriptionStorageConfig Queue="MyApp1Subscriptions" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp2.Messages" Endpoint="MyApp2" />
      <add Messages="MyApp3.Messages" Endpoint="MyApp3" />
      <add Messages="MyApp4.Messages" Endpoint="MyApp4" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

If you want to publish the same message type from all four applications, you can Bus.Send() the message to a central event publisher service, which could then Bus.Publish() it.

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