[jboss-user] [EJB3] - How do the timeouts work with EJB3 Stateful Beans

Administrator Administrator do-not-reply at jboss.com
Thu Jan 20 10:58:52 EST 2011


Administrator Administrator [http://community.jboss.org/people/admin] modified the document:

"How do the timeouts work with EJB3 Stateful Beans"

To view the document, visit: http://community.jboss.org/docs/DOC-9628

--------------------------------------------------------------
h2. EJB3 Timeouts with Stateful Session Beans

h3. When using stateful session beans, you can control the timeouts for.

1. How long the bean(with the state) remains in memory.  State can be passivated to disk(or cache) to free up memory for other beans or processes.
2. How long the bean remains active before it is completely removed.  This controls the life span of the SFSB.

h3. There are two timeouts that control this:

1. idleTimeoutSeconds - the number of seconds that a SFSB remains active but unused until the state is passivated.
2. removalTimeoutSeconds - this represents the end of the beans life, the bean and state are deleted when this timeout is hit but the bean was unused. 0 represents infinity. When removalTimeoutSeconds <= idleTimeoutSecond, then the bean is not passivated, it is just straightforwardly removed.

h3. You can change this in two places.  

h4. 1.  You can change the timeouts per bean by defining a class annotation.

For a clustered configuration specify a simple CacheConfig with your specific timeouts.  Remember that 0 is infinite.

*If you are NOT in a clustered app server..*

@CacheConfig (maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)

*If you are IN a clustered app server..*

@CacheConfig (name="jboss.cache:service=EJB3SFSBClusteredCache", maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)


h4. 2.  You can change these globally if you go to the deploy/ejb3-interceptors-aop.xml file.
You will see the following defined for clustered and non clustered SFSBs.  Just edit the file and replace the timouts that you would like.  Make sure that you change the correct one if you are clustered or non-clustered.  You may want to change both for constancy.


   <annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.CacheConfig) AND !class(@org.jboss.annotation.ejb.Clustered)">
         @org.jboss.annotation.ejb.cache.simple.CacheConfig (maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
      </annotation>

      <!-- Clustered cache configuration -->
      <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND class(@org.jboss.annotation.ejb.Clustered)">
         @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.tree.StatefulTreeCache.class)
      </annotation>
      <annotation expr="!class(@org.jboss.annotation.ejb.cache.tree.CacheConfig) AND class(@org.jboss.annotation.ejb.Clustered)">
         @org.jboss.annotation.ejb.cache.tree.CacheConfig (name="jboss.cache:service=EJB3SFSBClusteredCache", maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
      </annotation>


*Warning:*Be careful what you set the removalTimeoutSeconds to.  If you are in the middle of a session and bean is not touched, it's possible that you could end up in a condition where you are depending on the state, you haven't touched it in the given timeout and the state is suddenly gone.  You will get the following errror...

javax.ejb.EJBNoSuchObjectException: Could not find Stateful bean: 41z4l26-wb41k6-ev4j007b-1-ev4jirql-bw

ref:
(1.) timout setting for seam.  JbossTimeoutSettingForSeam
--------------------------------------------------------------

Comment by going to Community
[http://community.jboss.org/docs/DOC-9628]

Create a new document in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2029]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110120/bd6b7c85/attachment-0001.html 


More information about the jboss-user mailing list