users@glassfish.java.net

Re: JCA - cleanup call for ManagedConnection too early?

From: <glassfish_at_javadesktop.org>
Date: Fri, 14 Sep 2007 00:40:00 PDT

Hi binod,

> http://java.sun.com/j2se/1.4.2/docs/api/javax/transaction/xa/XAResource.html#end(javax.transaction.xa.Xid,%20int)
>
> You can see that XAResource.end marks the end of the transaction.

The javadocs say for the end() call: "The resource manager ... lets the transaction complete". Obviously the javadoc is not precise here as it is not the transaction that is complete at the time of the end() call but only the "work performed on behalf of a transaction branch" (qoute from X/Open XA Specification) has ended. So, with the end() call only the user portion of the transaction has finished; the system has to keep the transactional resources locked until commit/rollback.

> However, it does turn a double edged sword that all the resource adapters are not clean enough to reuse the physical connection right after the end() call.

There might be a difference when a resource adapter wraps a database. But for a resource adapter wrapping access to an EIS the physical connection is by no means free for other communication at the time of end() as for many EIS the commit/rollback needs to be transmitted on the same physical connection as the user data. So, calling cleanup right after end() causes problems for a resource adapter wrapping an EIS as it has to prevent the reuse of the physical connection before commit/rollback.

> I agree that safest approach might be to do the cleanup() after the commit/rollback.

This would make life easier for the resource adapter.

Clemens
[Message sent by forum member 'ctee' (ctee)]

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