简体   繁体   English

在不同平台上使用 Web 服务的分布式事务

[英]Distributed transaction using web services on different platforms

is it possible to achieve transactionality using web services that are implemented in different technologies?是否可以使用以不同技术实现的 Web 服务来实现事务性?

For example: let's imagine a case where we want to offer an integrated service of 2 different organizations, each of which already have their different systems implemented using different technologies and located in different countries.例如:让我们想象一下我们想要提供 2 个不同组织的集成服务的情况,每个组织都已经使用不同的技术在不同的国家实施了不同的系统。 Organization A has a Java server exposing Rest services that allow consumers to insert data in a table, then Organization B has a.Net server exposing Rest services that also allow consumers to insert data in a table.组织 A 有一个 Java 服务器公开 Rest 服务,允许消费者在表中插入数据,然后组织 B 有一个 .Net 服务器公开 Rest 服务,也允许消费者在表中插入数据。 Then I want to create a new server to integrate both these services in one, allowing consumers to insert in both organization's databases.然后我想创建一个新的服务器来将这两个服务集成到一个,允许消费者插入两个组织的数据库。 So from this new server I have to invoke those 2 rest services in a transactional way (meaning that both organizations will insert or none will insert if there is a failure, it will rollback).因此,我必须从这个新服务器以事务方式调用这两个剩余服务(这意味着两个组织都将插入,或者如果出现故障则不会插入,它将回滚)。

Is that possible to achieve even tho server 1 and server 2 are implemented with different technologies?即使服务器 1 和服务器 2 使用不同的技术实现,也有可能实现吗? What if there were n servers all implemented in different technologies and all exposing Rest services?如果有 n 个服务器都以不同的技术实现并且都公开 Rest 服务怎么办?

It is not possible to have real transactions in case of microservice architecture.在微服务架构的情况下,不可能有真正的交易。 You have to implement compensations which roll back changes in case of failures.您必须实施补偿,以在发生故障时回滚更改。 See Saga pattern for one of the approaches.有关其中一种方法,请参阅Saga 模式

Look at the Cadence Workflow that makes implementing Sagas trivial.查看Cadence Workflow ,它使 Sagas 的实施变得微不足道。 Here is an example. 这是一个例子。

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

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