当前位置:网站首页>Using rabbitmq to implement distributed transaction
Using rabbitmq to implement distributed transaction
2020-11-07 16:49:00 【PHP open source community】
RabbitMQ The idea of solving distributed transaction :
Case study : Classic case , In the case of the current popular takeout , After the user orders , Call the order service , Let the post order service call the dispatch system to inform the delivery personnel to deliver the order , At this time, the order system and dispatch system adopt MQ Asynchronous communication .
RabbitMQ Solve the principle of distributed transaction : Using the principle of final consistency .
The following three elements need to be guaranteed
1、 Confirm that the producer must deliver the data to MQ Server ( use MQ Message confirmation mechanism )
2、MQ Consumer news can consume information correctly , Use manual ACK Pattern ( Note the idempotency problem of retrial )
3、 How to ensure that the first transaction is executed first , Using compensation mechanism , Create a replenishment consumer to monitor , If the order is not created successfully , Make up the order .
If the producer delivers a message to MQ Server success
scene 1: If the consumer fails to consume the news , The producer does not need to roll back the transaction .
Solution : Consumers use manual ack Response mode , use MQ Compensation and retrial mechanism , Be careful MQ The problem of compensating idempotency .
problem : How to ensure that producers deliver messages to MQ The server will succeed ?
Solution :confirm Mechanism ( Confirmation response mechanism ).
scene 2 If the producer delivers a message to MQ Server failed , How to solve ?
Solution : Using the producer retry mechanism to send messages , Pay attention to idempotency .
scene 3 How to ensure that a transaction is executed first , The producer delivers a message to MQ Server success , Consumer spending is successful , But the order rolled back .
Solution : Replenishment mechanism .
Traditional solutions :
RabbitMq Solution :
版权声明
本文为[PHP open source community]所创,转载请带上原文链接,感谢
边栏推荐
- Do you really know how to use search engines?
- 如何创建交互式内核密度图表
- Exclusive interview with Yue Caibo
- Dynamsoft barcode reader v7.5!
- Empty test suite appears in JUnit test
- 小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
- 2020年新规,微信封号怎么快速解除?
- Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found
- 2020-08-20: the difference between go and python?
- Python 3 operates the Jenkins module API
猜你喜欢
Using JSON webtoken (JWT) to generate token in nodejs
VARCHART XGantt入门教程
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
南京标志设计,logo设计公司
Reserved battery interface, built-in charge and discharge circuit and electricity meter, quickly help easily handle hand-held applications
Win7 how to quickly type CMD and get to the required directory
如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题
Jenkins installation and deployment process
Talk about sharing before paying
Dynamsoft barcode reader v7.5!
随机推荐
Points to be considered when deleting mapping field of index in ES
OpenCV計算機視覺學習(10)——影象變換(傅立葉變換,高通濾波,低通濾波)
2020年新规,微信封号怎么快速解除?
September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.
Python3 operating gitlab
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
8.Swarm创建维护和水平扩展Service
Blazor 準備好為企業服務了嗎?
And how to solve the conflict between pop-up menu and pop-up menu
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
关于DevOps的七大误解,99%的人都曾中过招!
2020-08-29: process thread differences, in addition to the inclusion relationship, the underlying details?
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
Win7 how to quickly type CMD and get to the required directory
Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found
Do you really know how to use search engines?
测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
垃圾分类知识竞赛
Developing STM32 USB with cubemx
win7如何快速打cmd并到达所要的目录