| Author |
web services and transactions
|
Ravi Danum
Ranch Hand
Joined: Jan 13, 2009
Posts: 104
|
|
Hello,
Question 1:
I have an EJB web service. If the web service is invoked from another EJB which is in the middle of a transaction, and the web service has the transaction attribute set to: TransactionAttributeType.REQUIRED, will a new transaction be created in the web service, or will the caller's transaction be used?
Question 2:
I have a servlet based web service which invokes a stateless session bean with TransactionAttributeType.REQUIRED set. If another EJB that is currently in a transaction invokes the servlet based web service, will the stateless session bean invoked by the web service always create a new transaction?
Thanks so much.
Ravi
|
 |
Peer Reynders
Bartender
Joined: Aug 19, 2005
Posts: 2906
|
|
Why do you think an SLSB exposed as a web service cannot support "mandatory"?
Because the transaction does not propagate over the HTTP/SOAP link.
"required" will always start a new transaction.An SLSB being accessed as a web service is being accessed as a web service - not as an SLSBAn EJB client accessing a web service has no idea whether the web service is actually based on a SLSB - so EJB features don't apply.
See also Servlet endpoint Vs EJB endpoint
|
"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
|
 |
Peer Reynders
Bartender
Joined: Aug 19, 2005
Posts: 2906
|
|
|
Now if both ends have Project Tango installed then WS-AtomicTransaction is used to propagate transactions over the web service link. But that is a very special case...
|
 |
Ravi Danum
Ranch Hand
Joined: Jan 13, 2009
Posts: 104
|
|
Peer,
I am deploying my web service on Glassfish which I believe has Tango. Will I have to configure it to get the behavior you mentioned? I am so glad for your response.
Many Thanks.
Ravi
|
 |
Peer Reynders
Bartender
Joined: Aug 19, 2005
Posts: 2906
|
|
I'm not sure but I wouldn't be surprised if it is automatically active as part of WSIT on Glassfish. Something about WS-AtomicTransaction automatically working for SLSBs and that it can be used manually on servlets.
About the basicWSTX Example
So Glassfish-to-Glassfish and Glassfish-to-Microsoft WCF should work. But I haven't come across any evidence that either WS-AtomicTransaction or WSIT are part of Java EE 5. Though JBoss 5 seems to include WS-AtomicTransaction support.
But it is probably safer to look at this as WS-AtomicTransaction support - not EJB transaction support - it would be surprising if things lined up perfectly.
|
 |
Ravi Danum
Ranch Hand
Joined: Jan 13, 2009
Posts: 104
|
|
Thanks, Peer. I wouldn't be aware of this without your help. There may be cases where we want the web service to be part of its caller's transaction. This is very helpful.
Many thanks.
Ravi
|
 |
 |
|
|
subject: web services and transactions
|
|
|