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.

qbisson
  • 185
  • 2
  • 12
  • 1
    I have been researching this issue and found that people uses Saga pattern. This is not a complete answer, so putting it in comment. http://arnon.me/soa-patterns/saga/ – ReVolly Jan 22 '14 at 20:48
  • Just a question but you have looked at JTA? – Namphibian Jan 23 '14 at 05:44
  • 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? – qbisson Jan 23 '14 at 20:21

2 Answers2

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

Arnon Rotem-Gal-Oz
  • 25,469
  • 3
  • 45
  • 68
  • 1
    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. – qbisson Jan 24 '14 at 20:59
  • 2
    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 successfully – Arnon Rotem-Gal-Oz Jan 24 '14 at 22:19
  • Thank you. We will try to implement this in our project. I'll try to investigate the Saga Pattern more in depth. – qbisson Jan 28 '14 at 21:30
  • 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! – CMCDragonkai Apr 08 '14 at 02:28
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.

Beezer
  • 1,084
  • 13
  • 18
  • 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? – qbisson Aug 11 '16 at 14:58
  • 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: http://docs.oasis-open.org/ws-tx/wstx-wsat-1.2-spec-cs-01/wstx-wsat-1.2-spec-cs-01.html – Beezer Aug 12 '16 at 20:19