• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help in stateless and stateful beans

 
Dharmesh Chheda
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello people

I have some queries.
It is known that the container, at times, passivates the stateful session beans and stores them in some secondary storage in a serialized form. Later when the client with which the bean is binded,invokes a method.... the container activates the bean and the serialized object is read back in the memory and converted to in-memory bean.
It is also know that we can set the timeout of a stateful session bean.
Now consider the following scenario
_____________________________

A client invokes a method on a stateful session bean which executes some code. Then there is no conversation between the bean and the client .. So the container , either using the LRU algo or some other passivation algo, passivates the bean to a secondary storage.
NOTE:- the session timeout of the bean is set to 10 minutes.
Now the client ends his session with the site.. what happens to the serialized bean which is stored in the database?.. what happens if the bean is kept in the database for more that 10 minutes ( which is the bean session timeout ) .. will the container keep the track of all the beans in the database and check on regular intervals about the states each bean is ..
please reply to me ... as to whether i am going on the right track .. or i have messed up the whole concept.
Bye
and
Thanx in advance
[ February 19, 2002: Message edited by: Dharmesh Chheda ]
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you making the proper distinction between timeout of the appserver Session object and a timeout for a Session EJB? They are really two different kinds of things.
The actual persistency for a Stateful Session EJB is handled by your activate and passivate code, which is called when the bean itself is being recycled. By default, most EJB servers maintain internal consistency with the backing store but not with any updates or deletions to that backing store from external sources (this way they can avoid the overhead of monitoring for external changes).
Although there are many who disagree, I recommend that you use Entity EJBs for DBMS-backed objects rather than Session EJBs. After all, they are designed to provide the session EJB functionality plus be more aware of persistency concerns.
If you're a purist (or expect a lot of changes in the system) put business logic in a Session EJB and have it reference Entity EJB(s) for the persistent data.
 
Dharmesh Chheda
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Tim thanks for replying
here i am using visual age for java .. and in that i am setting the bean properties as stateless and stateful along with a session timeout in case of stateful beans.
Then i tested a code..
what i did is that i created a stateful session bean and kept its timeout as 2 seconds.. then through a servlet i obtained an instance of the bean and made the thread sleep for 4 seconds.. after which i invoked a method on the bean class.
but it gave me the error


which means that the bean has been destroyed after the timeout.. so what in case of passivation?.. i really cant get hold of this
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!