This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes CMT - Pooled connection availability Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "CMT - Pooled connection availability" Watch "CMT - Pooled connection availability" New topic
Author

CMT - Pooled connection availability

Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
Hi
I have a stateless session bean, whose transactions are container managed,
Lets say I am calling a method sslb() as below:

Now When I close the connection in step 5, will the connection be available to the next user request OR container will wait till step 6 is completed then do a commit/rollback and then release the connection for next user?

Thanks
Vinay Raj
Ranch Hand

Joined: Jun 19, 2006
Posts: 81
If the transaction is a 1PC, even after closing the connection, the connection object will not be released to the pool. The connection will be retained until the transaction is rollbacked or committed. That should happen at the end of the method call.

To overcome this problem, move your data processing code outside the method or make the transaction BMT. Using BMT you can control the transaction semantics and thus define the transactional boundaries.

In case of 2PC, the connection object involved in CRUD (Create, Read, Update and Delete) operations and commit or rollback need not be the same. 2PC uses a combination of xid a unique identifier and branch to identify the transaction in progress. Thus it can use two different connection objects for CRUD and commit/rollback operations.
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
Thanks.
So do you mean that in a 2PC the connection is immediately available after closing it?
Vinay Raj
Ranch Hand

Joined: Jun 19, 2006
Posts: 81
That will depend upon the application server implementation, but the 2PC protocol is designed such that the application server can free up resources. Each application server will have its own optimization philosophy around this. So unfortunately one cannot predict if the resource release will happen or not.
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
Could you suggest some references with such info?
Thanks
Vinay Raj
Ranch Hand

Joined: Jun 19, 2006
Posts: 81
Unfortunately I do doubt you will get any documented information. You would need to look up blogs. For information on websphere visit their developerworks site.

Sorry that I could not provide you specific inputs on the same.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CMT - Pooled connection availability
 
Similar Threads
how to read specific data from a web page..
Transactions in BMP
how we should return a connection to connectio pool
refreshing a connection
EJB opening too many connections to DB