How to use transactions and rollbacks in an SOA architecture
Asked Answered
C

2

7

I'm currently working on a SOA project.

I have to develop several processing chains, that is to say a web-services that chain web-services inside an ESB in Java.

Since every web-service to chain can throw different exception, I thought about using Transactions to be able to rollback the web-services behaviors.

However, I have no idea if this is even possible in an SOA environnement when every service is different. I searched it and found some information about AtomicTransactions but I'm not sure it's can be used to solve my problem.

To conclude, my questions are is it actually possible to rollback services? And if so, how can I set it up?

Thanks in advance.

Carbonado answered 22/1, 2014 at 19:13 Comment(3)
I have been researching this issue and found that people uses Saga pattern. This is not a complete answer, so putting it in comment. arnon.me/soa-patterns/sagaMaplemaples
Just a question but you have looked at JTA?Stewart
I haven't used JTA much but is it possible to use it in a distributed environnement? I thought there had to be a different way to do it since the concerns are someway different. Do you have any link that could help me set up transactions in an SOA or is it plain JTA? Is there some special annotations?Carbonado
K
10

Using transactions between services is not a good practice as you're holding up resources for components that are not necessarily trustworthy, plus service processes are usually long-running (I wrote about it more in "transactional-integration anti-pattern".

As someone mentioned in a comment I find that the "saga pattern" is a better way to handle these long running interactions

Keitel answered 24/1, 2014 at 20:20 Comment(4)
Thanks. I searched for the "saga pattern and if I understand it correctly, it means I have to compensate the actions done by the services. Do the services need a method to cancel an service method? For example, when an add() method is executed, does it have to call aremove() method on the service when an exception is thrown? Or is there any other way to implement this? For informations, our project is using an orchestration component to call the different services.Carbonado
if you are orchestrating everything from the outside you can indeed call the reverse action on the service. Another way is to have the external orchestrator just coordinate the saga and just let the services know it failed. Then each service can handle the failure internally doing the best it can to rollback or compensate in some other manner. Services can also maintain leases on their promises and rollback independently if the lease isn't renewed and/or the saga wasn't committed successfullyKeitel
Thank you. We will try to implement this in our project. I'll try to investigate the Saga Pattern more in depth.Carbonado
If we leave each service to do its own reversal, what happens if the service that failed also stopped running, in which case it could not publish a failure event letting the other services know that they need to rollback. Then this transaction would be in limbo!Sclerodermatous
C
0

I find the whole idea bad at best. SOA and transactions has always been a huge headache. Advocating the reverse action of a set of services, can ALSO fail! What would you do then?

I know of a very reputable media company in the UK, that has a dedicated offshore team, massaging data, due to orchestration failures across web services, which, boggles the mind.

Finally, with OEM BPM engines as orchestrators I think there might be a capability to rely on for a Unit of Work concept. However, this topic has been and amazingly is still an issue.

Copolymerize answered 10/8, 2016 at 10:0 Comment(2)
I don't really understand why you would think having transactions in an SOA architecture would be bad. I really think there should be a way to do this, maybe in the protocols to add a notion of transactions across services without having to implement it ourselves. Now, i know it's not an easy feat because there would still be other problems but how can you keep your application integrity without this?Carbonado
hi. actually I dont think they are bad. I just say, that doing a compensation is not a good idea. Also, just found out that my reply is actually erroneous. There are, since I was last on a SOA project, OASIS standards, for transactions, that have been implemented with Oracle Weblogic 11 for example: docs.oasis-open.org/ws-tx/wstx-wsat-1.2-spec-cs-01/…Copolymerize

© 2022 - 2024 — McMap. All rights reserved.