Clustering with Stateful Session Beans in JBoss

Stateful Session Beans have a state for a client Fail-over and Reliability ⇒ Fault-tolerant State managed by JBoss Cache To enable clustering for SFSB, it works the same way as clustering SLSB except that:

  • There is only one load-balancing policy available: FirstAvailable (default for SFSB)
  •  This time JBoss Cache is used because the state has to be managed


To enrich your career and become a JBoss professional, visit Tekslate, the global online training platform:" JBoss Training". This course will help you achieve excellence in this field.

sfsb-cache cache configuration is located in:

  • deploy/cluster/jboss-cache-manager.sar/META-INF/jboss-cache-configs.xml(You can enable this file in the JBoss-cache-manager-jboss-beans.xml file): Describes cache configuration using the standard JBC 3.x config format
  •  deploy/cluster/jboss-cache-manager.sar/META-INF/jboss-cache-manager-jboss-beans.xml: Describes cache configuration using the microcontainer format

These configurations affect all SFSB. You can override this configuration for your SFSB though:

  • By annotating with @org.jboss.ejb3.annotation.CacheConfig
  •  In the jboss.xml file with <cache-config>...</cache-config>

The parameters you can configure are the following:

  •  idle-timeout seconds: Time in seconds an SFSB can be unused before being passivated (default 300)
  •  maxSize: maximum number of beans that can be cached (default 10000)
  • name: Specify the name of the cache configuration. sfsb-cache is the default for SFSB
  • removalTimeoutSeconds: Time in seconds an SFSB can be unused before being deleted by the cache (default 0)
  •  replicationIsPassivation: Should a replication be considered as passivation? (default true)

Example: To disable passivation, you could set idle-timeout seconds and maxSize to 0.

For an in-depth understanding on JBoss click on: