EAP 8 - how to configure Infinispan based distributed timers

Updated

EAP 8 has several different mechanisms for persistent EJB timers: a file-based implementation and a JDBC-based implementation. Of these, only the JDBC-based implementation is suitable for use in a cluster. However, this implementation does not scale well in large to medium sized clusters and relies on a single point of failure due to the blocking nature of the mechanism employed to determine which cluster member should schedule a given timer expiration.

EAP 8.0 has a new mechanism which uses Infinispan based distributed EJB Timers that is sutiable for use in a cluster that is both highly-available and reasonably scalable. This new timer service implementation uses the consistent hash of an Infinispan cache to determine which timers a given cluster member should manage.

The distributable timer service is enabled by default for the ejb3 subsystem for all the ha configurations, a user will be required to modify the default timer-service configuration if the JDBC based service should be used

            <timer-service default-persistent-timer-management="persistent" default-transient-timer-management="transient">

See also the distributable-ejb subsystem which contains the configuration for the persistentinfinispan-timer-management:

        <subsystem xmlns="urn:jboss:domain:distributable-ejb:1.0" default-bean-management="default">
            <infinispan-bean-management name="default" cache-container="ejb" max-active-beans="10000"/>
            <infinispan-client-mappings-registry cache-container="ejb" cache="client-mappings"/>
            <infinispan-timer-management name="persistent" cache-container="ejb" cache="persistent" max-active-timers="10000"/>
            <infinispan-timer-management name="transient" cache-container="ejb" cache="transient" max-active-timers="10000"/>
        </subsystem>

The max-active-timers setting control the number of timer data within the local memory, it will passivate unused entries and store it to disc.

And the infinispan subsystem:

        <subsystem xmlns="urn:jboss:domain:infinispan:14.0">
            <cache-container name="ejb" default-cache="dist" marshaller="PROTOSTREAM" aliases="sfsb" modules="org.wildfly.clustering.ejb.infinispan">
                <transport lock-timeout="60000"/>
                <local-cache name="transient">
                    <locking isolation="REPEATABLE_READ"/>
                    <transaction mode="BATCH"/>
                    <expiration interval="0"/>
                    <file-store passivation="true" purge="true"/>
                </local-cache>
                <distributed-cache name="persistent">
                    <locking isolation="REPEATABLE_READ"/>
                    <transaction mode="BATCH"/>
                    <expiration interval="0"/>
                    <file-store passivation="true"/>
                </distributed-cache>
                ...
            </cache-container>

The transient configuration will include all timers which are marked as non-persistent, those timers are executed on this cluster instance only, does not fail over to other nodes and will not survive a restart.
If the application is deployed on several nodes each node will execute the timer concurrently.

The persistent configuration will inlcude all timers which are marked as persistent timers, those timers are executed once and only once within the cluster and fail over if the executing node is no longer available, also survive a full cluster restart.

Category
Components
Article Type