http://stackoverflow.com/questions/30696351/a-single-channel-with-multiple-consumers-rabbitmq

Typically the IModel.BasicConsume() registration is used to connect a single consumer through a single channel. However, the documentation is clear that multiple consumers can be registered through a single channel. For example:

Channel channel = ...;
Consumer consumer1 = ...;
Consumer consumer2 = ...;
channel.basicQos(10); // Per consumer limit
channel.basicConsume("my-queue1", false, consumer1);
channel.basicConsume("my-queue2", false, consumer2);

The above snippet is taken from this link. The documentation goes on to clarify the disadvantage of doing this:

Each Channel has its own dispatch thread. For the most common use case of one Consumer per Channel, this means Consumers do not hold up other Consumers. If you have multiple Consumers per Channel be aware that a long-running Consumer may hold up dispatch of callbacks to other Consumers on that Channel.

The disadvantage is spelled out clearly. What is missing is the explanation of why positively it may be useful to do this. Does anyone know? What is the advantage?

Furthermore, there is another similar scenario to consider. Evidently it is also possible to multiply register the same consumer.

Channel channel = ...;
Consumer consumer = ...;
channel.basicConsume("my-queue1", false, "queue1-Tag", consumer);
channel.basicConsume("my-queue2", false, "queue2-Tag", consumer);

In this latter case it is actually easier to envision the advantage; it allows multiple Rabbit queues to be multiplexed into a single event stream. But if it has that advantage, why is this approach so esoteric and completely undocumented? What makes this particularly weird is that the whole idea of a consumerTag ("queue1-Tag" and "queue2-Tag") seems to exist to support this scenario. Please note:

Is it possible for one consumer (one QueueingBasicConsumer) to register to multiple queues and have messages continually sent to it?

Certainly it is. When registering a Consumer you (either nominate, or) get a (server-generated) consumer tag, essentially an identifier for the Consumer. You only have to keep a map of tags so that the Consumer can know (when it is called) for which registration this callback is being made.

If you have a single channel connection to RabbitMQ, then the Consumers (each registration looks like a Consumer to the server) get called serially, so there is no concurrency. If you have many channels you can register for different queues on different channels and the distinct channels' callbacks can run concurrently.

The above Q&A came from this link.

If this is why consumerTag identifiers are used, why is this not stated clearly in the official documentation?

So to review the two scenarios:

  • What is the advantage of having multiple consumers registered through a single channel?
  • Why are multiple registrations of a single consumer practically discussed nowhere, even though it provides a seemingly self-evident benefit?

I'm coding in the context of .net and C#, though this question is really about RabbitMQ in general.

A Single Channel with Multiple Consumers RabbitMQ的更多相关文章

  1. a single statement, not multiple statements

    http://dev.mysql.com/doc/refman/5.7/en/prepare.html Statement names are not case sensitive. preparab ...

  2. memory runs at single channel问题解决

    memory runs at single channel 解决方案:开机后按DEL ,然后进入BIOS 选择第一项,回车! advanced下面的有个momori什么什么的,选择disable. m ...

  3. [Spark][Python]Mapping Single Rows to Multiple Pairs

    Mapping Single Rows to Multiple Pairs目的: 把如下的这种数据, Input Data 00001 sku010:sku933:sku02200002 sku912 ...

  4. Share single RDM between multiple VM's in ESX

    1.Create a VM01 on esx01,Create a VM02 on esx02 2.Create the RDM on your VM01 (using the virtual, no ...

  5. RabbitMQ Connector

    https://ci.apache.org/projects/flink/flink-docs-master/dev/connectors/rabbitmq.html RabbitMQ Source ...

  6. AMQP 0-9-1 Model Explained Why does the queue memory grow and shrink when publishing/consuming? AMQP和AMQP Protocol的是整体和部分的关系 RabbitMQ speaks multiple protocols.

    AMQP 0-9-1 Model Explained — RabbitMQ http://next.rabbitmq.com/tutorials/amqp-concepts.html AMQP 0-9 ...

  7. 《Single Image Haze Removal Using Dark Channel Prior》一文中图像去雾算法的原理、实现、效果(速度可实时)

    最新的效果见 :http://video.sina.com.cn/v/b/124538950-1254492273.html 可处理视频的示例:视频去雾效果 在图像去雾这个领域,几乎没有人不知道< ...

  8. paper 105: 《Single Image Haze Removal Using Dark Channel Prior》一文中图像去雾算法的原理、实现、效果及其他

    在图像去雾这个领域,几乎没有人不知道<Single Image Haze Removal Using Dark Channel Prior>这篇文章,该文是2009年CVPR最佳论文.作者 ...

  9. Single Image Haze Removal Using Dark Channel Prior

    <Single Image Haze Removal Using Dark Channel Prior>一文中图像去雾算法的原理.实现.效果及其他. Posted on 2013-08-2 ...

随机推荐

  1. django insert data into mysql

    #!/usr/bin/python # -*- coding:utf-8 -*- # @filename: search # @author:wwx399777 wuweiji # @date: 20 ...

  2. HTML页面中5种超酷的伪类选择器:hover效果

    想在自己的网站中应用超酷的hover效果吗?也许你可以从如下的这些实例中获得一些灵感,如果你喜欢这些效果,也可以直接拷贝代码并应用到你的站点. 给平淡的站点带来活力 hover效果能给网页增加一些动态 ...

  3. TWaver可视化编辑器的前世今生(一)电信网管编辑器

    走到今天,TWaver,一个致力于在技术领域(Technology)的弄潮儿(Waver),已经是第十二个年头.当年网吧的小网管都是IDC机房的运维人员了,TWaver也见证了这个时代的成长变迁. 萌 ...

  4. loj6063 Shadow

    题目描述 题解: 显然凸多面体投下来一定是个凸多边形. 对于$30$分,直接投到$x-y$平面上即可. 对于$100$分,考虑搞出平面的一般式方程$ax+by+cz+d=0$. 给出平面上三个点$A, ...

  5. Centos7安装tomcat(wget获取安装包)

    选择要下载的版本去tomcat库查看想要下载的版本 https://mirrors.cnnic.cn/apache/tomcat/ 下载选择tomcat8的一个版本 wget https://mirr ...

  6. 3. 对系统表空间使用Raw磁盘分区

    3. 对系统表空间使用Raw磁盘分区 可以将raw磁盘分区用作InnoDB系统表空间中的数据文件.此技术可在Windows和某些Linux和Unix系统上启用非缓冲I/O,而无需文件系统开销.使用和不 ...

  7. 页面布局排版-block,inline,float,relative,absolute等

    1.span和div的区别 div是块元素(block),span是行内元素(inline): span什么事也不会做,它存在的目的在与为开发者给它所围绕的元素指定样式.div类似,不过它引入了行分隔 ...

  8. 前端面试绝对会考的JS问题!【已经开源】

    写在前面 [前端指南]前端面试库已经开源,正在完善之中 [x] css问题 [x] html问题 [x] javascript问题 github地址 https://github.com/nanhup ...

  9. POJ 1287 Networking (最小生成树模板题)

    Description You are assigned to design network connections between certain points in a wide area. Yo ...

  10. hihocoder 1584 Bounce (数学 && 规律) ACM-ICPC北京赛区2017网络赛

    题意: 给定一副n*m的格子图, 问从左上角的点开始往右下角滑,碰到墙壁就反弹, 碰到角落就停止, 问恰好经过一次的格子有多少个. 如图,恰好经过一次的格子有39个. 分析: 首先要引入两个概念, “ ...