当前位置:网站首页>消息队列的丢失、重复与积压问题
消息队列的丢失、重复与积压问题
2022-06-23 11:03:00 【InfoQ】
案例背景

案例分析
- 系统解耦:用 MQ 消息队列,可以隔离系统上下游环境变化带来的不稳定因素,比如京豆服务的系统需求无论如何变化,交易服务不用做任何改变,即使当京豆服务出现故障,主交易流程也可以将京豆服务降级,实现交易服务和京豆服务的解耦,做到了系统的高可用。
- 流量控制:遇到秒杀等流量突增的场景,通过 MQ 还可以实现流量的“削峰填谷”的作用,可以根据下游的处理能力自动调节流量。
- 如何知道有消息丢失
- 哪些环节可能丢消息
- 如何确保消息不丢失
案例解答

- 消息生产阶段: 从消息被生产出来,然后提交给 MQ 的过程中,只要能正常收到 MQ Broker 的 ack 确认响应,就表示发送成功,所以只要处理好返回值和异常,这个阶段是不会出现消息丢失的。
- 消息存储阶段: 这个阶段一般会直接交给 MQ 消息中间件来保证,但是你要了解它的原理,比如 Broker 会做副本,保证一条消息至少同步两个节点再返回 ack(这里涉及数据一致性原理,我在 04 讲中已经讲过,在面试中,你可以灵活延伸)。
- 消息消费阶段: 消费端从 Broker 上拉取消息,只要消费端在收到消息后,不立即发送消费确认给 Broker,而是等到执行完业务逻辑后,再发送消费确认,也能保证消息的不丢失。
边栏推荐
- 当 Pandas 遇见 SQL,一个强大的工具库诞生了
- Implement common C language string processing functions
- Google Earth Engine(GEE)——GEDI L2A Vector Canopy Top Height (Ver
- 长安LUMIN是否有能力成为微电市场的破局产品
- 只出现一次的数字<难度系数>&& 杨辉三角<难度系数>
- Simplest DIY steel patriot machine gun controller based on Bluetooth, 51 MCU and steering gear
- The simplest DIY actuator controller based on 51 single chip microcomputer
- Noi OJ 1.3 16: calculating segment length C language
- Unity technical manual - limit velocity over lifetime sub module and inherit velocity sub module
- Argmax function notes - full of details
猜你喜欢

Whether Changan Lumin has the ability to become a broken product in the micro electricity market

Interview Manual of social recruitment Tencent high P (Senior Product Manager)

技术创造价值,手把手教你薅羊毛篇
[Architect (Part 40)] connecting mongodb database developed by server

Unity technical manual - limit velocity over lifetime sub module and inherit velocity sub module

New technology aesthetics and original biological networking operating system reshape the whole house intelligence

“芯”有灵“蜥”,万人在线!龙蜥社区走进 Intel MeetUp 精彩回顾

Experience of using thread pool in project

A child process is created in the program, and then the parent and child processes run independently. The parent process reads lowercase letters on the standard input device and writes them to the pip

Analysis of LinkedList source code
随机推荐
ESP32-CAM高性价比温湿度监控系统配网与上网方案设计与实现
Explain in detail the method of judging the size end
Interview Manual of social recruitment Tencent high P (Senior Product Manager)
JVM easy start-02
图片存储--引用
Why should poll/select use Nonblock when opening
今天14:00 | 12位一作华人学者开启 ICLR 2022
TTY drive frame
C语言结构体字节对齐问题
最简单DIY基于51单片机的舵机控制器
运行时应用自我保护(RASP):应用安全的自我修养
Noi OJ 1.3 11: C language for calculating the remainder of the division of floating-point numbers
一年多时间时移世易,中国芯片不断突破,美国芯片却难以卖出
STM32F103ZET6单片机双串口互发程序设计与实现
六张图详解LinkedList 源码解析
Noi OJ 1.3 16: calculating segment length C language
Whether Changan Lumin has the ability to become a broken product in the micro electricity market
Maui uses Masa blazor component library
1154. 一年中的第几天
php反射类使用