Physical routing with MSMQ

Component: MSMQ Transport | Nuget: NServiceBus (Version: 5.x)

MSMQ is a bus transport. This means that an MSMQ system consists of multiple nodes, one on each machine, forwarding messages between each other. Each endpoint connects to its local MSMQ node. In order to address a different endpoint, not only the queue name but also the host name has to be specified.

Scaling out

Because the MSMQ queues are not accessible from outside the machine they are hosted at, NServiceBus endpoints using the MSMQ transport are unable to use the competing consumers pattern to scale out with a single shared queue.

The distributor can be used to overcome this limitation.

Physical mapping

Host name of the machine running each endpoint can be specified directly in the message-endpoint mapping configuration section by adding @machine suffix.

Edit
<configuration>
  <configSections>
    <section name="UnicastBusConfig"
             type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>
  </configSections>
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Assembly="Sales.Messages" 
           Endpoint="Sales@VM-1" />
      <add Assembly="Billing.Messages"
           Endpoint="Billing@VM-2" />
    </MessageEndpointMappings>
  </UnicastBusConfig>
</configuration>

When using MSMQ, if there is no @machine part, NServiceBus assumes the configured endpoint runs on a local machine.

Related Articles


Last modified