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. qemu-img————QEMU的磁盘管理工具

    qemu-img command [command options] Command: check [-f fmt] filename                       # 对磁盘镜像文件进 ...

  2. oracle函数笔记(1)

    1.在数据库中显示当前时间:函数(sysdate) select sysdate from dual: 2.数据库中显示 :年/月/日 时/分/秒 ---函数:to_char(字段,'yyyy-mm- ...

  3. 如何实时查看mysql当前连接数?

    1.查看当前所有连接的详细资料: ./mysqladmin -uadmin -p -h10.140.1.1 processlist2.只查看当前连接数(Threads就是连接数.): ./mysqla ...

  4. LeetCode(66)Plus One

    题目 Given a non-negative number represented as an array of digits, plus one to the number. The digits ...

  5. 【C#】【数据结构】006-栈:链栈

    C#数据结构:链栈 1.自定义链栈结构: 链栈节点类 using System.Collections; using System.Collections.Generic; using UnityEn ...

  6. Java学习关于集合框架的基础接口--Collection接口

     集合框架(Collection  Framework)是Java最强大的子系统之一,位于java.util 包中.集合框架是一个复杂的接口与和类层次,提供了管理对象组的最新技术.Java集合框架标准 ...

  7. Git上传的使用步骤

    Git上传的使用步骤 首先 git branch 查看当前的分支是否为本地自己分支 接着 git stash 保存本地自己的保存 git checkout earemote 查看本地共有开发分支 gi ...

  8. Leetcode 301.删除无效的括号

    删除无效的括号 删除最小数量的无效括号,使得输入的字符串有效,返回所有可能的结果. 说明: 输入可能包含了除 ( 和 ) 以外的字符. 示例 1: 输入: "()())()" 输出 ...

  9. C# 中的新增功能

    百度搜索:C# 中的新增功能 微软有站点专门介绍:C# 中的新增功能. 地址:https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-new/inde ...

  10. python中的“坑”—持续更新

    1.判断是否是回文 def is_back(s): ]==(s if s.strip() else False) print(is_back('上海自来水来自海上')) print(is_back(' ...