Search code examples
publish-subscribenservicebus-distributor

NServiceBus: PubSub with Distributor on a different machine from Publisher and Subscriber


I've got the PubSub sample working with a distributor in the middle - all of them on my local machine. Now I'm trying to get the distributor on to a different machine and having trouble. The subscribers seem to be getting registered with the publisher via the distributor (I've added log statements in the Publisher which tells me the number of subscribers and that gives me the right value), but the subscriber just doesn't get any of the published events. What am I doing wrong? Is there some permissions I need to provide for the different queues? Here're my config files:

Publisher:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
  </configSections>

  <MsmqTransportConfig InputQueue="MyPublisherInputQueue" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5" />

  <UnicastBusConfig DistributorControlAddress=""
    DistributorDataAddress=""
    ForwardReceivedMessagesTo="">
    <MessageEndpointMappings>
        <add Messages="MyMessages" Endpoint="distributorDataBus@rosmi" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

</configuration>

Subscriber:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
  </configSections>

 <MsmqTransportConfig
    InputQueue="Subscriber1InputQueue_1"  
    ErrorQueue="error"
    NumberOfWorkerThreads="1"
    MaxRetries="5"
  />

  <UnicastBusConfig  DistributorControlAddress="distributorControlBus@rosmi" DistributorDataAddress="distributorDataBus@rosmi">
    <MessageEndpointMappings>
      <add Messages="MyMessages" Endpoint="MyPublisherInputQueue" /> <!-- I've also tried this with MyPublisherInputQueue@rrajagop -->
    </MessageEndpointMappings>
  </UnicastBusConfig>

</configuration>

Distributor:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="NumberOfWorkerThreads" value="1"/>

    <add key="DataInputQueue" value="distributorDataBus"/>
    <add key="ControlInputQueue" value="distributorControlBus"/>
    <add key="ErrorQueue" value="error"/>
    <add key="StorageQueue" value="distributorStorage"/>

    <add key="NameSpace" value="http://www.UdiDahan.com"/> 
    <!-- relevant for a Serialization of "interfaces" or "xml" -->

    <add key="Serialization" value="xml"/>
    <!-- can be either "xml", or "binary" -->
  </appSettings>
</configuration>

In the above config, the distributor is running on a machine called "rosmi" and the publisher and subscriber are running on "rrajagop".


Solution

  • Figured out the problem: the issue was happening because nslookup of the machine name was pointing to the wrong IP address - this was because of DHCP allocating a different IP to the machine, but dns entries taking a while to update.