wood burning stoves 2.0*
The moose likes Web Services and the fly likes Roolback and transaction boundary across multiple apps in Web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Roolback and transaction boundary across multiple apps in Web service" Watch "Roolback and transaction boundary across multiple apps in Web service" New topic
Author

Roolback and transaction boundary across multiple apps in Web service

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
How to best demarcrate transaction boundary across multiple applications that use web services?

For example, from a client application (e.g. App1, which is the client) make a call to another application (e.g. App2, which has web services method). Will it be possible to rollback in App2, if something falis down the stream by making the entire call (App 1 to App 2 and the return result back to App1) a part of single transaction?

I understand that web service itself does not have any notion of transaction? One option is, based on the return result, I may have to programmatically issue rollback or so.

What are different options available for doing rollback etc. in web services environment that span multiple applications?
Chintan Rajyaguru
Ranch Hand

Joined: Aug 19, 2001
Posts: 341
I am not sure if I understand your question correctly so I am going to paraphrase with my understanding:

App1 (Client) calls App2 (web service) and then App3 (web service). If something goes wrong downstream, you want to roll back the transaction and want both App2 and App3 to be restored to their pre-transaction states.

If this is what you want then the answer is yes. You can do that using standards such as WS-AT (Web Service AtomicTransactions). You can use this standard only if both client and web service can support it. So you need to look at the web service runtime you are using. From your question, I guessing that you have the same runtime on both sides. Check your server documentation. I am aware that WebSphere and Glassfish support transactions in web service. Each runtime has different way to actually configure the transaction settings.

There are also other alternatives to using WS-AT if your architecture and design allows. For example, if App2 and App3 are both Java/J2EE, you could put them behind a facade and make the facade transactional.

Hope this helps...


ChintanRajyaguru.com
SOADevelopment.com - Coming soon!
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Sam Gehouse:
What are different options available for doing rollback etc. in web services environment that span multiple applications?


Transaction protocols like WS-BusinessActivity or WS-AtomicTransaction exist to support transactions across multiple services - however two-phase (2PC) commit is considered a form of tight-coupling. It is considered preferable to design your services for compensation instead (Your Coffee Shop Doesn�t Use Two-Phase Commit (PDF))
Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
Could somebody suggest sample code/tutorial/example implementation of Web Services Atomic transaction? It would be even nice, if I could find some example using WebSphere 5.1.2 and 6.1. I looked at few of the sites on this. Most of the sites talked about the specifications, not implementations.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Websphere Applications Server - Express, Version 6.1: Web Services Atomic Transaction support in WebSphere Application Server
developerWorks: Develop enterprise apps with WS-AT and JTA, Part 1
Chintan Rajyaguru
Ranch Hand

Joined: Aug 19, 2001
Posts: 341
Originally posted by Sam Gehouse:
How to best demarcrate transaction boundary across multiple applications that use web services?


I have sent you an email with some specific directions. But let's address this question real quick.

If you are writing an CMT EJB, you can mark transaction boundary declaratively in the deployment descriptor. If you are writing a web based (war) client or J2EE application client, you can obtain a reference to UserTransaction using java:comp/UserTransaction lookup.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Roolback and transaction boundary across multiple apps in Web service