Ability to configure default global stateful timeout for Stateful Session Beans

In  ejb

Overview

Issue Metadata

Issue

Dev Contacts

QE Contacts

Testing By

[x] Engineering

[x] QE

Affected Projects or Components

  • ejb3

Other Interested Projects

Requirements

The standard way to configure stateful bean session timeout for each ejb is via @StatefulTimeout annotation, or stateful-timeout in ejb-jar.xml. But WildFly currently (version 18) lacks the ability to configure a default global stateful bean session timeout for all deployed stateful beans. This feature is useful to deploy and configure multiple stateful beans consistently in a server instance or cluster.

Hard Requirements

  • Users should be able to configure default global stateful timeout in server config file for all deployed stateful session beans.

    • If this configuration is absent, the current behavior should be preserved (i.e., stateful session beans do not timeout unless explicitly removed by application)

    • add this configuration via CLI

    • remove this configuration via CLI

    • update this configuration to a new value via CLI

    • read this configuration value via CLI

  • @StatefulTimeout annotation in bean class should override this default global stateful timeout in server config file

  • stateful-timeout in ejb-jar.xml should override this default global stateful timeout in server config file

  • when neither @StatefulTimeout nor stateful-timeout is present, the configured default-stateful-bean-session-timeout should take effect.

Expected CLI Operations and resources

[standalone@localhost:9990 /] /subsystem=ejb3:read-attribute(name=default-stateful-bean-session-timeout)
{
"outcome" => "success",
"result" => -1
}
[standalone@localhost:9990 /] /subsystem=ejb3:write-attribute(name=default-stateful-bean-session-timeout, value=6000)
{"outcome" => "success"}

Nice-to-Have Requirements

  • None

Non-Requirements

  • ability to configure default global stateful timeout in WildFly admin console

  • ability to specify default global stateful timeout in custom time unit

  • ability to immediately apply the updated default global stateful timeout value to deployed stateful beans

Implementation Plan

  • add a new attribute, default-session-timeout to ejb3 subsystem schema, for example,

<xs:complexType name="stateful-beanType">
    ...
    <xs:attribute name="default-session-timeout" type="xs:integer" default="-1" use="optional">
        <xs:annotation>
            <xs:documentation>
                The default session timeout, for stateful session beans, in milliseconds
            </xs:documentation>
        </xs:annotation>
    </xs:attribute>
<subsystem xmlns="urn:jboss:domain:ejb3:7.0">
<session-bean>
    <stateless>
        <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
    </stateless>
    <!-- add new attribute default-session-timeout -->
    <stateful default-session-timeout="600000"
      default-access-timeout="5000" cache-ref="simple" passivation-disabled-cache-ref="simple"/>
    <singleton default-access-timeout="5000"/>
    ...
</session-bean>
  • This new configuration will appear as a new attribute (default-stateful-bean-session-timeout) under ejb3 subsystem resource:

[standalone@localhost:9990 /] /subsystem=ejb3:read-resource
{
"outcome" => "success",
"result" => {
    ...
    "default-stateful-bean-session-timeout" => -1,
    ...
}

Test Plan

New tests will be added to wildfly/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/stateful/timeout, and existing test case in that directory will be enhanced to verify the new feature.

  • structural tests with CLI CRUD operations of the new attribute default-stateful-bean-session-timeout

    • write attribute default-stateful-bean-session-timeout to -1, 0, and 1000, and then read and verify the attribute value

    • rewrite the attribute to some other value, and then read and verify the updated attribute value

  • behavioral tests of default stateful session timeout

    • when this attribute is absent in server config file, a stateful session bean should not timeout and be removed. This is the existing behavior before this RFE is implemented.

    • when this attribute is set to a certain value, a stateful session bean should timeout and subject to removal after this duration (there could be some delay between timeout and actual removal)

    • @StatefulTimeout annotation in bean class should override this attribute in server config file

    • stateful-timeout in ejb-jar.xml should override this attribute in server config file

  • transformer tests should be added to Ejb3TransformersTestCase

Community Documentation

Enhance WildFly community docs (docs/src/main/asciidoc/_admin-guide/subsystem-configuration/EJB3.adoc) to describe the new attribute default-stateful-bean-session-timeout and affected changes.