Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Stateful session bean passivation

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB 3.x Specs Chapter 4, section 4.2

A Container may only passivate a stateful session bean instance when the instance is not in a transaction



Can anyone elaborate on this little bit more ?
Generally session bean invocation takes place in transaction context and I thought whether to do the passivation or not will be determined by container on the basis of max-cache-size of beans or idle time out period .

 
Creator of Enthuware JWS+ V6
Posts: 3339
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ravi,

Can anyone elaborate on this little bit more ?


This just means that passivation should only been done when the session bean is idle (that is: not involved a transaction)

Generally session bean invocation takes place in transaction context and I thought whether to do the passivation or not will be determined by container on the basis of max-cache-size of beans or idle time out period .


How and when to use passivation is not prescribed in the specs, and therefore up to the container developers

This is what the specs say about it:

EJB spec 4.2 "To efficiently manage the size of its working set, a session bean container may need to temporarily transfer the state of an idle stateful session bean instance to some form of secondary storage. The transfer from the working set to secondary storage is called instance passivation. The transfer back is called activation. "



Regards,
Frits
 
Ravi Bansal
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the Reply Frits.

I agree when you say how and when passivation should be done , is upto container implementation. I should have been more specific about weblogic when I mentioned about idle-time-out and max-cache-size.

But going back to original question of Session bean will not be passivated if its in transaction.

In case my Java EE client (say another EJB having some transaction context) is calling a stateful session bean multiple methods . that means across the different method calls of stateful , it will never be passivated.
Do you agree?

Say if i have Something like below in my client program calling stateful session bean methods method1(), method2(), method3() and each of the methods in stateful session bean having transaction attribute as SUPPORTS OR REQUIRED



Begin transaciton
look up JNDI and get the bean reference
call method1()
call method2()
call method3()
End transaction.



So in above between any of the method calls (say between method1() and method2() invocations ) , Stateful Session bean will never be passivated as they will be running in transaction context of caller EJB.
Am i right ?

Thanks in Advance


 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3339
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In case my Java EE client (say another EJB having some transaction context) is calling a stateful session bean multiple methods . that means across the different method calls of stateful , it will never be passivated.
Do you agree?


Yes, that is correct

So in above between any of the method calls (say between method1() and method2() invocations ) , Stateful Session bean will never be passivated as they will be running in transaction context of caller EJB. Am i right ?


Yes! the Stateful Session Bean (SSB) is registered in the transactional context of the client, so the containers knows it is busy and that it should not passivate the SSB.

Regards,
Frits
 
Ravi Bansal
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot for quick response Frits.
 
Get me the mayor's office! I need to tell her about this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic