Masstransit and RabbitMQ - how many consumers are connected

时光怂恿深爱的人放手 提交于 2019-12-12 19:18:06

问题


I am using MassTransit and RabbitMQ in both a "competing consumers" model and a Pub/Sub model.

3 tiers, 1st tier = UI, 2nd tier = gateway, 3rd tier = many distributed services

I have a working competing consumers model but I wish to do the following with Pub/Sub:

The gateway service publishes a message that all connected subscriber instances consume and then respond to to the gateway. The gateway doesn't respond to the UI until all its 3rd tier have responded, the gateway accumulates the response and finally passes back to the UI.

I cannot find a way to inspect MassTransit (whether I use SAGAs or not) in the 2nd tier to know how many subscribers i have in the 3rd tier (to work out if they've all responded). The overall goal is that the UI gets a single response with the accumulated results from the 3rd tier.

A similar question is here - no answers as yet.

UPDATE

Effectively I want to count the number of sinks on the inboundPipeline. Should I be doing this and is there a clean way to do it?


回答1:


Pub/Sub in general doesn't allow you to know how many consumers for a given message exist. The whole idea is that you aren't coupled to that answer.

To do this, you need to build the solution into your application to keep track of that. When a consume comes up, publish a message for the gateway to register with it. When it shutdowns, do the same to remove that registration.



来源:https://stackoverflow.com/questions/20347748/masstransit-and-rabbitmq-how-many-consumers-are-connected

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