简体   繁体   English

在Spring Boot应用程序中使用RabbitMQ进行分布式事务

[英]Distributed transactions with RabbitMQ in spring boot application

Currently working on migrating a monolith app into micro services and I want to know how to achieve the distributed transaction in across application. 目前正在致力于将Monolith应用程序迁移到微服务中,我想知道如何在整个应用程序中实现分布式事务。 Is there any examples for RabbitMQ handling distributed transaction? 是否有任何RabbitMQ处理分布式事务的示例?

please note that this is not a duplicate question. 请注意,这不是重复的问题。 also i come with some example but i didn't find any implementation. 我也举了一些例子,但我没有找到任何实现。

http://lifeinide.com/post/2017-12-29-spring-boot-rabbitmq-transactions/ http://lifeinide.com/post/2017-12-29-spring-boot-rabbitmq-transactions/

Generally in microservices world, distributed transaction using 2PC protocol is discouraged as it slow and not scalable. 通常,在微服务领域,不鼓励使用2PC协议进行分布式事务,因为它速度慢且不可扩展。 Rather a pattern known as Saga is recommended. 而是建议使用一种称为Saga的模式。 Failures are rolled-back using compensation steps or activities in reverse order. 使用补偿步骤或活动以相反顺序回滚失败。 The whole idea is to let microservices do only local transactions and the transaction which span across microservices should be done in a scalable manner and using a strategy where failed transactions can be logically compensated locally. 整个想法是让微服务仅执行本地事务,跨微服务的事务应以可伸缩的方式进行,并使用可以对失败的事务进行本地逻辑补偿的策略。 Saga pattern can use a messaging broker where events can be pushed to and listened to - this is where you can use RabbitMQ. Saga模式可以使用消息传递代理,在该代理中可以推送和监听事件-在这里可以使用RabbitMQ。 An example project can be seen here and here . 这里这里都可以看到一个示例项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM