当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 南京标志设计,logo设计公司
- 2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
- Talk about sharing before paying
- Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
- Git SSH bad permissions
- 【QT】QThread原始碼淺析
- Composition of MRAM cache
- Image processing toolkit imagexpresshow to view events
- k-vim安装及The ycmd server SHUT DOWN (restart with ':YcmRestartServer')这种错误的解决方法
- ImageMagick - add watermark
猜你喜欢
9. Routingmesh service communication between clusters
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
Bluetooth broadcast chip for Shanghai giant micro
How to add modules to nginx image?
三步轻松理解Kerberos协议
如何才能快速正确的部署甘特图
Idea activation to 2089 failure
Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
QT audio and video development 46 video transmission UDP version
如何创建交互式内核密度图表
随机推荐
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
应用层软件开发教父教你如何重构,资深程序员必备专业技能
Stm32f030c6t6 compatible to replace mm32spin05pf
The method of local search port number occupation in Windows system
大佬们如何在nginx镜像里面增加模块?
.NETCore3.1+ Vue.js Low code workflow engine
VARCHART XGantt入门教程
win7如何快速打cmd并到达所要的目录
Count the number of project code lines
VARCHART XGantt如何在日历上表示工作日
Nanjing logo design and production, guide VI system design
2020-08-15: under what circumstances should data tasks be optimized?
Talk about sharing before paying
“非洲用户的付费意愿并不低”——专访四达时代研发总监张亮
Experiment one
Google browser realizes video playback acceleration function
甘特图对活动进行分组教程
使用RabbitMQ实现分布式事务
南京标识标牌设计制作,导视VI系统设计
Using JSON webtoken (JWT) to generate token in nodejs