开发者

NServiceBus: Trouble getting PubSub working with Distributor

I'm using NServiceBus 2.5 and trying to get a simplified version of the NServiceBus PubSub sample working with the distributor. The simplification:

  • 1 Publisher
  • Distributor
  • 1 Subscriber All of this is on a single machine.

I would like to get this working before I move on to more complex things like multiple subscribers behind a single distributor, multiple machines, etc.

First I got the simplified pub sub example working without the distributor (i.e 1 pub and 1 sub - and I got that working fine).

As I understand it, the way it should work is: The distributor defines its own control and data queues. The publisher has it's control queue, but no other config refers to this queue. The publisher refers to the distributes data queue. The subscriber refers to the distributors data and control queues.

I've not been able to get the simplified pub-sub distributor working with this config. I've done some debugging of the publisher and what I've found is that the publisher's Bus.Publish doesn't find any subscribers to publish to.

Any ideas what I'm doing wrong and what I need to do to get this working?

Here's configs for eac开发者_开发问答h of those:

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>
    <MessageEndpointMappings>
        <add Messages="MyMessages" Endpoint="distributorDataBus" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

</configuration> 

Distributor

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

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" DistributorDataAddress="distributorDataBus">
    <MessageEndpointMappings />
  </UnicastBusConfig>

</configuration>


Ok, I finally got this working. The key clue came from here: http://tech.groups.yahoo.com/group/nservicebus/message/8525

Basically, the subscriber needs to be pointed to the publisher by adding this section:

<UnicastBusConfig  DistributorControlAddress="distributorControlBus" DistributorDataAddress="distributorDataBus">
  <MessageEndpointMappings>
    <add Messages="MyMessages" Endpoint="MyPublisherInputQueue" />
  </MessageEndpointMappings>
</UnicastBusConfig>

I initially thought that this is making the subscriber register directly with the publisher, but no. I tested that out with two different subscribers pointed to the same distributor and noted that only one of the subscribers gets any single event published.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜