[jboss-user] [EJB 3.0] - Re: Stateful bean keep-alive

PeterJ do-not-reply at jboss.com
Fri May 15 14:06:14 EDT 2009


Don't set removalTimeoutSeconds, use idleTimeoutSeconds instead. See http://www.jboss.org/community/wiki/HowdothetimeoutsworkwithEJB3StatefulBeans This way unused beans are passivated and thus don't remain in memory. You can also set removalTimeoutSeconds to a large value, such as 8 hours. That way if the client really went away, the bean will be removed from the passivation storage are after a while.

Creating a new client thread might work, but you have to be careful. First, the thread must not lookup the EJB itself - you will end up with a new EJB, not with the one that you want to keep alive. Therefore, you must pass the bean's proxy to the thread. Second, I recommend creating a separate method on the EJB that does nothing - the primary purpose of this method is for the extra thread to occasionally call it. This should guarantee that the state of the bean does not change inadvertently.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4231381#4231381

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4231381



More information about the jboss-user mailing list