How to disable Stateful Session EJB (SFSB) clustering while leaving Stateless EJB (SLSB) clustering enabled in JBoss EAP 7

Solution Verified - Updated

Environment

Red Hat JBoss Enterprise Application Platform (EAP) 7

Issue

  • How to disable Stateful Session EJB (SFSB) clustering while leaving Stateless EJB (SLSB) clustering enabled in JBoss EAP 7

Resolution

Change the stateful cache-ref from distributable to simple.

The JBoss CLI command would be:

/subsystem=ejb3:write-attribute(name=default-sfsb-cache,value=simple)

Which changes from:

        <subsystem xmlns="urn:jboss:domain:ejb3:5.0">
            ...
                <stateful default-access-timeout="5000" cache-ref="distributable" passivation-disabled-cache-ref="simple"/>
            ...
            </session-bean>

to:

        <subsystem xmlns="urn:jboss:domain:ejb3:5.0">
            ...
                <stateful default-access-timeout="5000" cache-ref="simple" passivation-disabled-cache-ref="simple"/>
            ...
            </session-bean>

Note: With the above change, all instances are on memory without passivation. SFSB instances should be expired by @javax.ejb.StatefulTimeout or removing an instance by calling remove API annotated @javax.ejb.Remove when finishing the SFSB invocation.

Root Cause

In OCP 4, the default configuration brings stateful bean as simple (not clustered):

$ cat  cat /opt/eap/standalone/configuration/standalone-openshift.xml
...
            <session-bean>
                <stateless>
                    <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
                </stateless>
                <stateful default-access-timeout="5000" cache-ref="simple" passivation-disabled-cache-ref="simple"/>
                <singleton default-access-timeout="5000"/>
            </session-bean>

Diagnostic Steps

Note Do not change the infinispan cache-container ejb as this is used by SLSB's for clustering. This cache-container needs to remain a distributed-cache for SLSB's to remain clustered. If this is changed to local-cache then SLSB's would no longer function clustered.

            <cache-container name="ejb" aliases="sfsb" default-cache="dist" module="org.wildfly.clustering.ejb.infinispan">
                <transport lock-timeout="60000"/>
                <distributed-cache name="dist">
                    <locking isolation="REPEATABLE_READ"/>
                    <transaction mode="BATCH"/>
                    <file-store/>
                </distributed-cache>
            </cache-container>
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.