users@glassfish.java.net

Re: Start a transaction from client and propagate it to server

From: <glassfish_at_javadesktop.org>
Date: Wed, 18 Apr 2007 18:07:35 PDT

Hi,

Once clarification, when you say "client", what do you mean? Is client a broswer or swing app? Is the client another server-side application that wants to call two web services that are part of another glassfish application? Or is the client a Servlet or another Java EE component within the same application as the web services? Or what?

Generally, UserTransaction is not used across client calls if the client is a browser or swing app etc, as it is not really meant to have a client make a call to server and start a transaction & do some stuff and return to client, then have client make another request to server and do some more stuff, then close/commit transaction and return to client again. This is something that people mistakenly try to do in web browser web apps too. In these cases you should not leave the transaction open. Each web request from the client should have its own transaction.

Can you reconsider changing your application design to have a single webservice endpoint, and that endpoint code starts a UserTransaction and then accesses the DB and then access the JMS resource, and then ends that transaction? That is the more typical use that UserTransaction is intended for, which is a component running in Java EE app starts a transaction and then access one or more transactional resources(DBs or JMS queues etc).

Generally with SOAP web services the transactional info is not propogated along when you make several calls to other services. The support to pass all the info along is just not there in SOAP web services. This type of support to pass along the transactional context among calls is part of RMI-IIOP so you can get this behavior for example if you have an EJB component call another EJB component using RMI-IIOP.

Propogation of the transaction context and other info for web services is functionality that is added to web service through some of the other WS-* specs. But its not part of the core web services standards like SOAP.

hth,
Sean
[Message sent by forum member 'sean_brydon' (sean_brydon)]

http://forums.java.net/jive/thread.jspa?messageID=213058