Masstransit和RabbitMQ-已连接多少消费者 [英] Masstransit and RabbitMQ - how many consumers are connected

查看:312
本文介绍了Masstransit和RabbitMQ-已连接多少消费者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在竞争消费者"模型和Pub/Sub模型中都使用MassTransit和RabbitMQ.

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

3层, 第一层 =用户界面,第二层 =网关,第三层 =许多分布式服务

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

我有一个有效的竞争消费者模型,但我希望对Pub/Sub做以下事情:

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

网关服务发布一条消息,所有连接的订户实例都将使用该消息,然后响应该网关.直到网关的所有第3层都做出响应,网关才对UI做出响应,网关积累响应并最终传递回UI.

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.

我无法找到一种方法来检查第二层中的MassTransit(是否使用SAGA)以了解我在第三层中有多少个订户(计算出他们是否都做出了响应).总体目标是使UI从第3层获得累积结果的单一响应.

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.

更新

有效地,我想计算inboundPipeline上的接收器数量.我应该这样做吗,有没有一种干净的方法呢?

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?

推荐答案

Pub/Sub通常不允许您知道给定消息有多少个使用者.整个想法是,您不会与该答案耦合.

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.

这篇关于Masstransit和RabbitMQ-已连接多少消费者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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