

Ask HN: Transactions over multiple web services - kokokaka

Hi guys,
to make it short: Is there a preferred way/nice solution for wrapping multiple web service calls in a transaction? I have to build a new "integrating" web service atop 2-3 legacy web services, so say for example:<p>def register(user) {
  callWebService1(user);
  callWebService2(user);
  callWebService3(user);
  doSomeOtherStuff(user);
}<p>Also let's assume I can still make some changes to the old web service interfaces or add some more methods.<p>Any "light-weight" best practices?<p>Thanks!
======
vyrotek
It depends on how 'idempotent' the service calls are. If it's safe to retry
the entire register method over and over again then it's pretty simple to keep
track if anything blew up during the process and then just try from the top
again.

If those services cannot be safely retried then you'll need to deal with
calling other operations on the services to roll back the changes if anything
goes wrong. I worked on a system that had a similar problem (not idempotent
and we actually didn't have way to delete/rollback changes through their
service) so we had to log every call made for context. That way if any service
failed we could retry the whole operation and skip over the things that were
successful.

