2

NServiceBus を使用して、4 つのアプリケーションを一緒に通信させようとしています。

これらのアプリケーションはすべて、パブリッシャーおよびサブスクライバーとして機能する必要があります。

私が見つけた唯一の方法は、すべてのアプリケーション構成の MessageEndpointMappings がマップされる Server という名前の「マスター」キューを作成することですが、それは良い方法ではないと思います...

では、これを機能させるには、これらすべてのアプリケーションで 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>
4

1 に答える 1

4

NServiceBusは、1つのサービスによってのみ公開される特定のメッセージタイプのパターンに従うことをお勧めします。通常、サービスごとに「メッセージ」アセンブリがあります。例:

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

4つのアプリケーションすべてから同じメッセージタイプを公開する場合は、メッセージを中央のイベントパブリッシャーサービスにBus.Send()して、中央のイベントパブリッシャーサービスにBus.Publish()することができます。

于 2010-05-20T00:34:50.020 に答える