Reputation: 11143
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>
Upvotes: 2
Views: 1796
Reputation: 4742
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.
Upvotes: 4