English 中文(简体)
NServiceBus - Application as subscriber and worker service
原标题:

I have a service which needs to run on multiple machines picking jobs off of a single queue ensuring each job is only undertaken by a single service. I also need to publish messages for all services to receive, such as reload triggers.

Is this possible in nservicebus without too much hacking?

I have proved that both the publish model and send model work for me but as soon as my client needs to deal with both architectures, it treats them all as a send architecture and not all services receive the publish methods.

Here are the config files I have so far:

Publisher (all services need to receive these messages), uses Bus.Publish<...>(...):

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

  <UnicastBusConfig DistributorControlAddress="" DistributorDataAddress="" ForwardReceivedMessagesTo="">
<!-- Message publishers don t require message queues -->
<MessageEndpointMappings />  </UnicastBusConfig>

Sender (only one service can pick these up), uses Bus.Send<...>(...):

  <MsmqTransportConfig InputQueue="BrokerQueue" ErrorQueue="error" numberOfWorkerThreads="1" MaxRetries="5" />

  <UnicastBusConfig DistributorControlAddress="" DistributorDataAddress="" ForwardReceivedMessagesTo="">
<MessageEndpointMappings>
  <add Messages="EventMessage, Messages" Endpoint="AgentQueue" />
</MessageEndpointMappings>  </UnicastBusConfig>

Services (each have the same local queue name and subscribe to the publisher above):

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

  <UnicastBusConfig>
<MessageEndpointMappings>
  <add Messages="NServiceBus.Messages.ReloadMessage, NServiceBus.Messages" Endpoint="ConfigQueue" />
</MessageEndpointMappings>  </UnicastBusConfig>
问题回答

Load balancing between different machines is accomplished with the Distributor that comes with NServiceBus. (remote transactional reads are flaky on MSMQ and is not recommended)

So all you sends would go to the same input queue, BrokerQueue in you case. You would then configure the distributor to feed of that queue.

More info on how to configure the distributor can be found here:

http://tech.groups.yahoo.com/group/nservicebus/message/2009

Hope this helps!





相关问题
synchronized message with nservicebus

I have a web service that needs to make a call to nservicebus in a synchronized manner. How can this be achieved ?

How do I correctly pool multiple message in NServiceBus?

I have an NServiceBus app which receives a particular message when a large database update is required. While this update is happening, I want to either somehow ignore all incoming messages of this ...

NServiceBus - Application as subscriber and worker service

I have a service which needs to run on multiple machines picking jobs off of a single queue ensuring each job is only undertaken by a single service. I also need to publish messages for all services ...

Server architecture question. (WCF+NServiceBus)

First of all i will describe current state: Server consists of several WCF services, hosted in one or several win services on diffirent machines. Service responsible for recieving data from ...

MSMQ Access issue in NServiceBus with asp.net web service

I am trying to implement publisher - subscribe in my project of asp.net (wcf) web services. When i am trying to create bus in global.asax protected void Application_Start(object sender, EventArgs e)...

How to configure nservicebus msmqtransport with code

I m just geting started with NServiceBus and can t figure out what I m missing when configuring the MsmqTransport in code. If I configure the publisher like this; IBus bus = Configure.With() ...

Getting the NServiceBus Distributor Sample To Work

I m trying to use the Distributor in the NServiceBus FullDuplex sample but I can t get it working. I ve been following the this guide Getting the NServiceBus Distributor Working, but it doesn t work. ...

热门标签