How do you handle a two phased commit in an SOA environment?

There are four approaches (and a couple of the can be combined). The first is to implement on top of XP compliant data bases that allow the services to accept a commit to but still wait for the final confirmation. Given the heterogeneity of most environments this is highly unlikely. The second is to design “compensating transactions” and have the middleware handle it. So for instance if one transaction charges something to your credit card and a subsequent part of the complex transaction fails, the compensating transaction issues a credit to the first service in the amount of the charge. The final two recommended practices, are to design the problem away and to handle exceptions as exceptions. In most cases we’ve seen two phase commit is more hypothetical than real, but in the cases where it has been real it is more advantageous to redesign the applications or services so that the two commits are in the same app, and that the side effect of successful posting is forwarded to the rest of the enterprise. In the event that this doesn’t lead to a 100% solution you should turf it off to your exception process, which you need for other purposes anyway.
Scroll to top