相关文章推荐
风流的春卷  ·  Javascript ...·  1 年前    · 
稳重的哑铃  ·  64位windows10python3安装p ...·  1 年前    · 
追风的作业本  ·  VS2019新建空白解决方案_vs空白解决方 ...·  1 年前    · 
谦和的苦瓜  ·  git 统计两个 commit ...·  2 年前    · 
千杯不醉的拖把  ·  惠来·回来·会来,游玩惠来指南攻略(最全最新 ...·  2 年前    · 
Code  ›  从RabbitMQ Channel设计看连接复用开发者社区
rabbitmq
https://cloud.tencent.com/developer/article/1696142
愉快的黄豆
9 月前
心平气和

从RabbitMQ Channel设计看连接复用

前往小程序,Get 更优 阅读体验!
立即前往
腾讯云
开发者社区
文档 建议反馈 控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
发布
首页
学习
活动
专区
工具
TVP 最新优惠活动
返回腾讯云官网
心平气和
首页
学习
活动
专区
工具
TVP 最新优惠活动
返回腾讯云官网
社区首页 > 专栏 > 从RabbitMQ Channel设计看连接复用

从RabbitMQ Channel设计看连接复用

作者头像
心平气和
发布 于 2020-09-11 11:23:55
2.1K 2
发布 于 2020-09-11 11:23:55
举报
文章被收录于专栏: 程序员升级之路

今天公司有同事在做RabbitMQ的分享的时候,讲到了Connection和Channel的设计,有同学有疑惑,为什么不用连接池实现,而要通过Channel的方式实现呢?

先脑补下Connection和Channel的关系

即可以在一个连接上同时发送不同Channel的数据;

看下RabbitMQ官网对于Channel的解读:

Some applications need multiple connections to the broker. However, it is undesirable to keep many TCP connections open at the same time because doing so consumes system resources and makes it more difficult to configure firewalls. AMQP 0-9-1 connections are multiplexed withchannels that can be thought of as "lightweight connections that share a single TCP connection".

Every protocol operation performed by a client happens on a channel. Communication on a particular channel is completely separate from communication on another channel, therefore every protocol method also carries a channel ID (a.k.a. channel number), an integer that both the broker and clients use to figure out which channel the method is for.

A channel only exists in the context of a connection and never on its own. When a connection is closed, so are all channels on it.

For applications that use multiple threads/processes for processing, it is very common to open a new channel per thread/process and not share channels between them.

大概的意思就是: 一些应用需要同时创建多个连接到 broker 也就是 RabbitMQ 服务器上。然而因为防火墙的存在,很难同时创建多个连接。 AMQP 0-9-1 连接使用多个 channel 连接实现对单一 Connection 的复用。

 
推荐文章
风流的春卷  ·  Javascript window.opener.postMessage Cross Origin with multiple sub domains - Stack Overflow
1 年前
稳重的哑铃  ·  64位windows10python3安装pysqlcipher3,包括openssl和vc14_pythonsqlcipher,pysqlcipher资源-CSDN文库
1 年前
追风的作业本  ·  VS2019新建空白解决方案_vs空白解决方案_可乐还是甜的好的博客-CSDN博客
1 年前
谦和的苦瓜  ·  git 统计两个 commit 之间相差的次数_51CTO博客_git 切换到某个commit
2 年前
千杯不醉的拖把  ·  惠来·回来·会来,游玩惠来指南攻略(最全最新) - 知乎
2 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号