当前位置:网站首页>消息中间件的消费模式
消息中间件的消费模式
2022-06-10 14:13:00 【morningcat2018】
消息中间件的消费模式
Push 模式:
优势 可以尽可能快的将消息发送给消费者(在 Pull 模式下需要不断的拉取消息,因为并不知道消息队列中是否有新消息)
劣势 服务端并不知道消费端的消费能力,不停的发送消息可能在导致消费端缓存区溢出
ActiveMQ 中使用 prefetch limit 解决上述劣势
当推送消息的数量到达了perfetch limit规定的数值时,消费者还没有向消息中间件返回ACK,消息中间件将不再继续向消费者推送消息
如果消息的数量很少(生产者生产消息的速率不快),但是每条消息 消费者需要很长的时间处理,那么prefetch limit设置为1比较合适。
prefetch limit 设置成 0 意味着此时,消费者去轮询消息中间件获取消息。不再是Push方式了,而是Pull方式了。即消费者主动去消息中间件拉取消息。
Pull 模式:
优势 消费端可以按处理能力进行拉去
劣势 会增加消息延迟(消费者不知道何时有消息,只能不停的拉取消息,但又不能太频繁;所以一般都会设置一个时间,每隔一段时间去拉取一次,这个时间就是消息延迟时间)
各个消息中间件的实现
- RabbitMQ
- 消费者默认是推模式(也支持拉模式)
- Kafka 拉模式
- 利用“长轮询”来实现拉模式
- 消费者去 Broker 拉消息,定义了一个超时时间,也就是说消费者去请求消息,如果有的话马上返回消息,如果没有的话消费者等着直到超时,然后再次发起拉消息请求
- RocketMQ 拉模式
长轮询
RocketMQ长轮询
Kafka长轮询
边栏推荐
- QT将接收到的json数据(含中文)unicode转utf8
- 软件智能:aaas系统 度量衡及文法的形式规则
- 短文本重复率快速检测
- Yanrong looks at how to realize the optimal storage solution of data Lake in a hybrid cloud environment
- 【离散数学期复习系列】二、一阶逻辑(谓词逻辑)
- Docker部署一个Redis集群
- C multithreading learning note 3
- [big guy show] aiops in the eyes of Borui data, choosing the right track and the right people
- 列表、数组和张量之间的相互转化
- [discrete mathematics review series] III. concept and operation of sets
猜你喜欢

二叉树和图2

C#多线程学习笔记三

Flutter listview, column, row learning personal summary 2

Use of 5.8G microwave radar module, working principle and introduction of 5.8G microwave radar module

一次主从表集成流程开发过程
![[discrete mathematics review series] v. some special charts](/img/4d/a52ba801b0421245d5e3828defc96d.png)
[discrete mathematics review series] v. some special charts

算力网络照进现实,浩鲸科技如何构建?

C#多线程学习笔记二

【笔记】C语言数组指针、结构体+二维数组指针小记

Microsoft Word 教程,如何在 Word 中更改页边距、创建新闻稿栏?
随机推荐
2022山东省安全员C证复训题库及在线模拟考试
[discrete mathematics review series] i. propositional logic
Win10 virtual machine download and installation process
Anaconda installs opencv (CV2) and uses it in the jupyter notebook
在启牛开户安全么
Yanrong looks at how to realize the optimal storage solution of data Lake in a hybrid cloud environment
2022 examination question bank and online simulation examination for main principals of hazardous chemical business units
D:\setup Exe could not find the problem
[advanced MySQL] optimize SQL by using the execution plan explain (2)
短文本重复率快速检测
还在说大学排名是笑话?最新规定:世界top50大学可以直接落户上海!
Do you understand all these difficult memory problems?
2022 practice questions and online simulation test for the third batch of Guangdong Provincial Safety Officer a certificate (principal)
How to solve the problem that vmware tools are grayed out when VMware Workstation is installed
[Discrete Mathematical period Review Series] Second and first order Logic (precate Logic)
Binary tree and figure 1
[discrete mathematics review series] v. some special charts
Leetcode-56-merge interval
P3379 【模板】最近公共祖先(LCA)
【离散数学期复习系列】三、集合的概念及运算