当前位置:网站首页>使用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
边栏推荐
- The essence of transaction and the principle of deadlock
- Git SSH bad permissions
- JVM class loading mechanism
- Benefits and functions of auto maintenance app development
- 2020-08-29: process thread differences, in addition to the inclusion relationship, the underlying details?
- And how to solve the conflict between pop-up menu and pop-up menu
- Idea activation to 2089 failure
- How does varhart xgantt represent working days on a calendar
- 失眠一个整晚上
- VARCHART XGantt如何在日历上表示工作日
猜你喜欢

2020-08-15: under what circumstances should data tasks be optimized?

win7如何快速打cmd并到达所要的目录

Jenkins入门(二)声明式流水线Jenkins Pipeline

August 30, 2020: naked write algorithm: the nearest common ancestor of two nodes in a binary tree.

How to deploy Gantt chart quickly and correctly

Git submission specification

The essence of transaction and the principle of deadlock

VARCHART XGantt入门教程

Characteristics of magnetic memory chip STT-MRAM

Python3 operating gitlab
随机推荐
2020-08-17: how to solve data skew in detail?
To solve the problem that the data interface is not updated after WPF binding set
Common mathematical basic formulas of recursive and backtracking algorithms
August 18, 2020: introduce Mr process?
关于DevOps的七大误解,99%的人都曾中过招!
The use of Xunwei imx6 development board device tree kernel menuconfig
2020-08-19: what mechanism does TCP ensure reliability?
RFID fixed assets management system for fire equipment
Two dimensional code location and alarm system of Expressway
2020-08-20: the difference between go and python?
Configuration of AP hotspot on xunwei-imx6ull development board
2020-09-04: do you understand the function call convention?
August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
频收罚单的浦发银行:增收不增利,曾遭骗贷数亿元,内控缺位?
Es create a new index database and copy the old index library, practice pro test effective!
LEADTOOLS如何检测,读取和写入条形码
Composition of MRAM cache
FreeSWITCH视频会议“标准”解决方案
10000! Ideal car recalls all defective cars: 97 accidents have occurred and losses will be expanded
K-vim installation and the ycmd server shut down (restart with ': ycmrestartserver')

