-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Thread local pattern in a cluster.
PostPosted: Mon May 31, 2004 3:16 am 
Newbie

Joined: Mon May 31, 2004 2:52 am
Posts: 11
I was trying to use the thread local pattern for my hibernate application, and I am unconfortable with the following facts. (note: I am using j2ee transaction semantics-CMT)

Case1: If the tread local is handled at the servlet(presentation tier). That means the sevlet is responsible for calling the closeSession.

* If the application is deployed in a cluster,one of your ejb can call another ejb which resides in the second node. The transaction flow in this case would be for instance Container1Servlet1---->Container1EJB1---->Container2EJB2. Since Thread Local won't be propagated across containers, the Container2EJB2 will create a new session and use that. And now Container1Servlet1 is not aware of that session and it closes only the first session created by him.

Case2: If the thread local is handled by each of the EJBs. That means that each EJB method is responsible for calling the closeSession at the end of the execution.

* If the transaction flows is like Container1Servlet1---->Container1EJB1(M1-TXRequiresNew) ---->Container1EJB1(M2-TXRequired) In this scenario, I cannot implement the session-per-request or not even session-per-transaction and results in poor performance. Because M1 and M2 has to open and close the session by its own.

Any input would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 31, 2004 5:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
In the case of using SLSBs, I wrap the unit-of-work by the SLSB and CMT. There is never any calls to another SLSB from within the unit-of-work. The unit-of-work can be built using a rich Domain Model or DAO structure which makes use of the Thread local pattern. If modeled like this then there are no clustering issues. It also allows reliable and easy testing outside of the container.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.