配置端点以同时充当工作人员和订阅者 [英] Cofiguring an endpoint to act both as worker and subscriber

查看:30
本文介绍了配置端点以同时充当工作人员和订阅者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将端点配置为充当从分发者检索作业并订阅某种消息的工作者?

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.

推荐答案

工人不应该以这种方式使用 IFAIK.我认为要走的路是让您的中央订阅价格,当NewOrderMessage"到达时,用所需的价格(可能只有该特定订单中的产品的价格)丰富该数据,并向输入发送一个新的 ProcessOrderRequest分发者队列.

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.

这样有意义吗?

/安德烈亚斯

这篇关于配置端点以同时充当工作人员和订阅者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆