This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction Handling when accessing external systems

 
Srinivas Pittala
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

SuD is interacting with external system and external web services.
Is it good to use javax.transaction.UserTransaction for handling distributed transactions?

Thanks,
Sree
 
Rishi Shehrawat
Ranch Hand
Posts: 218
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Web services cannot participcate in JTA transactions.
The external system needs to be accessible via JCA to participate in JTA transactions.
 
Srinivas Pittala
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rishi,

Thanks for your response.
To consume external web services, generally we do not opt for JCA.Directly will invoke the link provided by web service providers
by writing a WS client(Session Bean--->WSPOJO--->External web services).

Is it the right way to handle a transactions in the following way by using container managed transaction attribute?
SuD invoke the session bean by using a controller

Appreciate your help.


@stateless
beanImplMethod(){
try{
invokeWebServiceMethod(){

//logic for invoking a web services...
}

}catch( Exception ex){
sessioncontext.setRollBackOnly()

}
}

Thanks,
Sree
 
Rishi Shehrawat
Ranch Hand
Posts: 218
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To the best of my knowledge there is no out of the box support for transaction managment of web services using JTA. The snippet provided by you will not work.
However there are ways to make it work by using WS-AtomicTransaction, WS-Coordination, however it comes at a cost in terms of increased complexity, performance, etc.
Have a look at (http://metro.java.net/guide/Using_Web_Services_Atomic_Transactions.html)
Normally you try to avoid all this complexity by writing compensating logic which works in conjuction with reconcilling logic for reconcilling your app with the external system via day end job or some other mechanisim.
 
Srinivas Pittala
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rishi,

Thank you very much for your repsponse..


Thanks,
Sree
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic