当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Experiment one
- 8. Swarm creates maintenance and horizontal extension service
- Nanjing logo design and production, guide VI system design
- idea 激活到 2089 失效
- 9.集群之间服务通信 RoutingMesh
- How to optimize the decoding performance of dynamsoft barcode reader
- 如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题
- Image processing toolkit imagexpresshow to view events
- Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
- Git SSH bad permissions
猜你喜欢
Using JSON webtoken (JWT) to generate token in nodejs
2020-08-29: process thread differences, in addition to the inclusion relationship, the underlying details?
VARCHART XGantt如何在日历上表示工作日
Composition of MRAM cache
Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
Application of UHF RFID medical blood management system
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
August 18, 2020: introduce Mr process?
Common mathematical basic formulas of recursive and backtracking algorithms
测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
随机推荐
August 14, 2020: what are the execution engines for data tasks?
Win7 how to quickly type CMD and get to the required directory
2020-08-20: the difference between go and python?
Detailed software engineering -- the necessary graphs in each stage
快進來!花幾分鐘看一下 ReentrantReadWriteLock 的原理!
The method of local search port number occupation in Windows system
python3操作gitlab
How to deploy Gantt chart quickly and correctly
ImageMagick - 添加水印
JS array the usage of array is all here (array method reconstruction, array traversal, array de duplication, array judgment and conversion)
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
Composition of MRAM cache
谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
如何才能快速正确的部署甘特图
2020-11-06: go, let's talk about the scheduler.
如何解决谷歌Chrome浏览器空白页的问题
【笔记】Error while loading PyV8 binary: exit code 1解决方法
pc端与移动端适配解决方案之rem
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
Insomnia all night