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. java缓存的使用

    缓存1,缓存的定义与作用2,缓存的使用范围(命中率高.高访问量)3,缓存策略(命中率,最大元素,清空策略);4,缓存介质(内存缓存,硬盘缓存,数据库缓存)(本地缓存(ehcache,oscache)与 ...

  2. HNOI2006 潘多拉的盒子

    题目描述 题解: 题目的描述比较长,理解起来也有一定难度.仔细读题后我们发现整个任务可以分成两个部分:找出咒语机之间所有的升级关系.求最长升级序列. 1. 求升级关系: 容易看出,咒语机i可以抽象成一 ...

  3. python字符串的格式化

    # -*- coding:utf-8 -*- """ @Author:janson @Date:2018/8/1 @File:StrFormat.py "&qu ...

  4. MySQL 存储 utf8mb4

    1.如果是阿里云数据库 a.控制台->修改参数character_set_server参数为UTF8mb4 b.设置库的字符集为UTF8mb4 2.如果是自己mysql服务器 [client] ...

  5. luogu4035 [JSOI2008]球形空间产生器

    如果单按照距离相等的话既是高次也没有半径,所以因为给了 \(n+1\) 组点就想到两两做差. 假如一组点是 \(\{a_i\}\) 一组是 \(\{b_i\}\),我们能轻易地得出 \[\sum_{i ...

  6. bzoj2973 入门oj4798 石头游戏

    我们人为地搞出来一个全能神,每次调用他他可以给一个节点 \(1\) 个石头. 这样,当前的状态就可以由上一秒的状态搞过来,这就像是一个递推.用矩阵加速. #include <iostream&g ...

  7. luogu4135 作诗

    看这里 #include <iostream> #include <cstring> #include <cstdio> #include <cmath> ...

  8. jenkins 提示No emails were triggered

    发送邮件 Jenkins->系统管理->系统设置,在“邮件通知”里设置smtp服务器地址,以及发送者邮箱地址,在具体的任务构建完成以后,可以设置发送邮件,在某一个任务的"Add ...

  9. SQL中varchar和nvarchar的基本介绍及其区别

    SQL中varchar和nvarchar的基本介绍及其区别 varchar(n) 长度为 n 个字节的可变长度且非 Unicode 的字符数据.n 必须是一个介于 1 和 8,000 之间的数值.存储 ...

  10. 校第十六届大学生程序设计竞赛暨2016省赛集训队选拔赛(Problem E)

    Problem E Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...