简体   繁体   中英

distributed transaction .net java SAP

I use several systems connected by Service oriented architecture, those systems include : .NET technology, Java WebLogic Service, and SAP RFC.

is it possible to achieve distributed transaction across these different technologies ? for example when updating SAP failed, we need to make sure that .NET, and Java transaction won't happen at all.

Really appreciate your input, or maybe you can point out where we can learn the basics how to do it?

I would do this as follows:

  1. Each interaction with the service is a Command with execute() and undo() methods defined.
  2. Maintain a stack of commands, push each command once it is successful.
  3. When a command fails, ie interaction with a service fails, pop each command from the stack and call undo() .

You might look for any Distributed Transaction APIs in .NET that would provide this functionality out of the box, though.

I would not recommend using distributed transactions between systems as it creates a lot of coupling between them and increases the load on each system as it holds locks for the others (you can see a write up I did on this called "transactional integration anti-pattern" ). Usually a better option, as suggested by Vikdor is using a Saga which you can coordinate manually or by some external coordinator (eg using Orchestration ).

Note that compensation logic might not be able to completely undo the operation (eg in a retail scenario, if an order caused you to hit an inventory threshold and order from your supplier a cancellation of that order doesn't have to cancel your order from your supplier. Also you may not refund the full sum etc. )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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