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

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

- 消息生产阶段: 从消息被生产出来,然后提交给 MQ 的过程中,只要能正常收到 MQ Broker 的 ack 确认响应,就表示发送成功,所以只要处理好返回值和异常,这个阶段是不会出现消息丢失的。
- 消息存储阶段: 这个阶段一般会直接交给 MQ 消息中间件来保证,但是你要了解它的原理,比如 Broker 会做副本,保证一条消息至少同步两个节点再返回 ack(这里涉及数据一致性原理,我在 04 讲中已经讲过,在面试中,你可以灵活延伸)。
- 消息消费阶段: 消费端从 Broker 上拉取消息,只要消费端在收到消息后,不立即发送消费确认给 Broker,而是等到执行完业务逻辑后,再发送消费确认,也能保证消息的不丢失。
边栏推荐
- Installation and use of binabsinspector, an open source binary file static vulnerability analysis tool
- Tensorrt笔记(四)推理分割模型
- 韦东山设备信息查询例程学习
- Verification code redis practice summary
- list的介绍及使用
- Win10 wireless network. If the system cannot search WLAN, the solution (and VMnet1, 8)
- ESP32-CAM高性价比温湿度监控系统
- Simplest DIY remote control computer system based on STM32 ① (capacitive touch + key control)
- 【ML】QuantileRegressor
- [Architect (Part 40)] connecting mongodb database developed by server
猜你喜欢

TTY drive frame

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

DevEco Device Tool 助力OpenHarmony设备开发

Installation and use of binabsinspector, an open source binary file static vulnerability analysis tool

Simplest DIY remote control computer system based on STM32 ② (wireless remote control + key control)

MAUI使用Masa blazor组件库

Flutter series: wrap in flutter

Win10 wireless network. If the system cannot search WLAN, the solution (and VMnet1, 8)

从0到1,IDE如何提升端侧研发效率?| DX研发模式

最简单DIY基于STM32F407探索者开发板的MPU6050陀螺仪姿态控制舵机程序
随机推荐
Win10 wireless network. If the system cannot search WLAN, the solution (and VMnet1, 8)
[use of Matlab graphical user interface controls]
Noi OJ 1.4 03: odd even judging C language
list的介绍及使用
Experience of using thread pool in project
Argmax function notes - full of details
Groovy之范围
Noi OJ 1.2 06: round floating point numbers to zero
Flutter series: wrap in flutter
UWA上新|真人真机测试新增海外机型专区
ESP32-CAM、ESP8266、WIFI、蓝牙、单片机、热点创建嵌入式DNS服务器
智慧园区效果不满意?请收下ThingJS这份秘籍
“芯”有灵“蜥”,万人在线!龙蜥社区走进 Intel MeetUp 精彩回顾
Maui uses Masa blazor component library
经济小常识
Not satisfied with the effect of the smart park? Please accept this secret script of thingjs
网上注册股票开户很困难么?现在网上开户安全么?
最简单DIY基于51单片机的舵机控制器
Why does the pointer not change the corresponding value as a formal parameter
Mysql-03. Experience of SQL optimization in work