当前位置:网站首页>使用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
边栏推荐
- 2020-11-06: go, let's talk about the scheduler.
- 插件Bilibili新版0.5.5
- 谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
- WebAPI接口设计:SwaggerUI文档 / 统一响应格式 / 统一异常处理 / 统一权限验证
- [graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
- 2020-11-06:go中,谈一下调度器。
- September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.
- Windows 10 蓝牙管理页面'添加蓝牙或其他设备'选项点击无响应的解决方案
- 汽车维修app开发的好处与功能
- How to optimize the decoding performance of dynamsoft barcode reader
猜你喜欢

Nodejs中使用jsonwebtoken(JWT)生成token的场景使用

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

Logo design company, Nanjing

How to deploy Gantt chart quickly and correctly

ImageMagick - add watermark

JS array the usage of array is all here (array method reconstruction, array traversal, array de duplication, array judgment and conversion)

win7 APPCRASH(解决方法)(转)

cubemx做stm32 USB开发

Erd-online free online database modeling tool

消防器材RFID固定资产管理系统
随机推荐
插件Bilibili新版0.5.5
移动端像素适配方案
A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
RFID fixed assets management system for fire equipment
2020-11-06:go中,谈一下调度器。
Image processing toolkit imagexpresshow to view events
如何创建交互式内核密度图表
Detailed software engineering -- the necessary graphs in each stage
Jenkins入门(二)声明式流水线Jenkins Pipeline
如何使用甘特图图层和筛选器
Git SSH bad permissions
The use of Xunwei imx6 development board device tree kernel menuconfig
测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
pc端与移动端适配解决方案之rem
August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
New features of vue3
7. Swarm builds clusters
2020年新规,微信封号怎么快速解除?
Do you really know how to use search engines?
Using JSON webtoken (JWT) to generate token in nodejs

