Cofiguring an endpoint to act both as worker and subscriber

和自甴很熟 提交于 2019-12-05 09:52:44

问题


Is it possible to configure an endpoint to act as a worker retrieving jobs from a distributor AND subscribe to some kind of messages?

I have the following scenario ( adapted to sale terminology)

*) a central department publishes every now and then a list of the new prices. All workers have to be notified. That means, a worker should subscribe to this event.

*) when a new order arrives at the central, it sends it to the distributor, which send it to the next idle worker to be processed. That means, a worker have to be configured to receive messages from the distributor. I use the following configuration:

 <MsmqTransportConfig
    InputQueue="worker"
    ErrorQueue="error"
    NumberOfWorkerThreads="2"
    MaxRetries="5"
  />

  <UnicastBusConfig
    DistributorControlAddress="distributorControlBus"
    DistributorDataAddress="distributorDataBus" >    
    <MessageEndpointMappings>
      <add Messages="Events" Endpoint="messagebus" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

When I configure it only as a worker or only as a subscriber everything works as expected, but not when I configure it as both.

I discovered that a message arrives at the input queue of the central with the address of the distributor as return address instead of worker address, and the publisher recognize no subscriber in this case. Any ideas? Thanks in advance.


回答1:


Workers are not supposed to be used in that way IFAIK. I think the way to go would be to have your central subscribe to the prices and when a "NewOrderMessage" arrives enrich that data with the required prices (perhaps only prices for the products in that particular order) and send a new ProcessOrderRequest to the input queue of the distributor.

Another way would be to have the process that sends the order request to include the prices in the order request.

Does that make any sense?

/Andreas




回答2:


Workers behind a distributor is how you scale out a single logical subscriber, not how you handle multiple logical subscribers. The point is that only a single worker out of the pool of workers should get a given message, in which case, you want all workers to look the same to the publisher - which is why the address of the distributor is given.

If you have multiple logical subscribers that you want to scale out, give each one of them their own distributor.



来源:https://stackoverflow.com/questions/1612581/cofiguring-an-endpoint-to-act-both-as-worker-and-subscriber

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!