Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Roolback and transaction boundary across multiple apps in Web service

 
Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chintan Rajyaguru
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic