Deferred Enlistment
In the WAS environment, deferred enlistment is a term used to refer to the technique of waiting until a connection is first used to enlist it in its unit of work (UOW) scope.
Benefits
Consider the following illustration of deferred enlistment:
- An application component that uses deferred enlistment calls the getConnection method from within a global transaction.
- The application component does not immediately use the connection.
- When the application issues the call for initial use of the connection, the transaction manager intercepts the call.
- The transaction manager enlists the XA resource for the connection and calls the XAResource.start method.
- The connection manager associated with the XA resource sends the call to the database.
Given the same scenario, but the application component does not use deferred enlistment, the component container immediately enlists the connection in the transaction. Thus the appserver incurs, for no purpose, an additional load of all of the overhead associated with that transaction. For XA connections, this overhead includes the two phase commit (2PC) protocol to the resource manager.
Deferred enlistment offers better performance in the case where a connection is obtained, but not used, within the UOW scope. The technique saves the cost of transaction participation until the UOW in which participation must occur.
Check with your resource adapter provider if know if the resource adapter provides this functionality. The WAS relational resource adapter automatically supports deferred enlistment.
Incorporating deferred enlistment in your code
The J2EE Connector Architecture (JCA) V1.5 specification calls the deferred enlistment technique lazy transaction enlistment optimization. This support comes through a marker interface (LazyEnlistableManagedConnection) and a new method on the connection manager (LazyEnlistableConnectionManager()):package javax.resource.spi; import javax.resource.ResourceException; import javax.transaction.xa.Xid; interface LazyEnlistableConnectionManager { // appserver void lazyEnlist(ManagedConnection) throws ResourceException; } interface LazyEnlistableManagedConnection { // resource adapter }
Related concepts
Transaction type and connection behavior
Connection pooling
Related Reference
Connection and connection pool statistics