当前位置:网站首页>使用RabbitMQ实现分布式事务
使用RabbitMQ实现分布式事务
2020-11-07 16:49:00 【php开源社区】

RabbitMQ解决分布式事务思路:
案例:经典案例,以目前流行点外卖的案例,用户下单后,调用订单服务,让后订单服务调用派单系统通知送外卖人员送单,这时候订单系统与派单系统采用MQ异步通讯。
RabbitMQ解决分布式事务原理:采用最终一致性原理。
需要保证以下三要素
1、确认生产者一定要将数据投递到MQ服务器中(采用MQ消息确认机制)
2、MQ消费者消息能够正确消费消息,采用手动ACK模式(注意重试幂等性问题)
3、如何保证第一个事务先执行,采用补偿机制,在创建一个补单消费者进行监听,如果订单没有创建成功,进行补单。
如果生产者投递消息到MQ服务器成功
场景1:如果消费者消费消息失败了,生产者是不需要回滚事务的。
解决方案:消费者采用手动ack应答模式,采用MQ进行补偿重试机制,注意MQ补偿幂等性问题。
问题:如何确保生产者投递消息到MQ服务器一定能成功?
解决方案:confirm机制(确认应答机制)。
场景2 如果生产者投递消息到MQ服务器失败,如何解决?
解决方案:使用生产者重试机制进行发消息,注意幂等性问题。
场景3 如何保证一个事务先执行,生产者投递消息到MQ服务器成功,消费者消费成功了,但是订单却回滚了。
解决方案:补单机制。
传统解决方式:
RabbitMq解决方案:

版权声明
本文为[php开源社区]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4479011/blog/4707610
边栏推荐
- git 提交规范
- How to create an interactive kernel density chart
- 轻量型 GPU 应用首选 京东智联云推出 NVIDIA vGPU 实例
- Detailed software engineering -- the necessary graphs in each stage
- Shanghai Pudong Development Bank, which frequently receives penalty tickets, has been cheated by hundreds of millions of yuan in loans, and lacks of internal control?
- Method of code refactoring -- Analysis of method refactoring
- Developing STM32 USB with cubemx
- vue3 新特性
- 2020-11-06: go, let's talk about the scheduler.
- Bluetooth broadcast chip for Shanghai giant micro
猜你喜欢

Using JSON webtoken (JWT) to generate token in nodejs

idea 激活到 2089 失效

List to map (split the list according to the key, and the value of the same key is a list)

August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)

The Interpreter pattern of behavior pattern

南京标志设计,logo设计公司

心理咨询app开发所具备的优点与功能
![yum [Errno 256] No more mirrors to try 解决方法](/img/3b/00bc81122d330c9d59909994e61027.jpg)
yum [Errno 256] No more mirrors to try 解决方法

How does varhart xgantt represent working days on a calendar

2020-11-06: go, let's talk about the scheduler.
随机推荐
Getting started with varhart xgantt
#JVM 类加载机制
消防器材RFID固定资产管理系统
September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.
如何使用甘特图图层和筛选器
Idea activation to 2089 failure
Composition of MRAM cache
2020-08-19: what mechanism does TCP ensure reliability?
1万辆!理想汽车召回全部缺陷车:已发生事故97起,亏损将扩大
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
你真的会使用搜索引擎吗?
Git submission specification
Developing STM32 USB with cubemx
Introduction to Jenkins (2) declarative pipeline
VARCHART XGantt入门教程
python3操作gitlab
实验一
QT audio and video development 46 video transmission UDP version
Logo design company, Nanjing
Git remote library rollback specified version

