3 Replies Latest reply on Sep 1, 2015 4:53 AM by wdfink

    Scheduler service in Wildfly 9

    sumanthreddybandi

      Hi,

       

      My application is running on JBoss 4.2.3 in a clustered environment. There is a scheduler service which pulls data from the database in every 10 sec. We achieved this by placing **-service.xml in deployments folder and by implementing "org.jboss.system.ServiceMBean" interface in JBoss 4.2.3.

       

      Now, i am upgrading jboss to Wildfly 9. As we cannot achieve scheduler service in wildfly with the existing mechanism(wildfly doesn't support org.jboss.varia.scheduler.SingleScheduleProvider), i am looking at alternatives EJB TimerService & ManagedScheduledExecutorService. Our requirement is to run the scheduled service only in one node of the cluster which we achieved using HASingletonDeployer.

       

      My qns:

      1. Which is better - EJB TimerService or ManagedScheduledExecutorService? My Scheduler task should invoke only if the previous task is finished i.e. i don't need concurrent tasks.

      2. How can we achieve that the scheduled task/method is run only on one node in a cluster?

       

      Please suggest. Thanks in advance.

        • 1. Re: Scheduler service in Wildfly 9
          wdfink

          Timer service would be my choice.

          If you use a singleton the scheduled timer run only once as the Singleton will lock concurrent executions.

          The HASingleton approach is only needed if you want to ensure to run the service once in your cluster.

           

          Another approch with WildFly9 is to use the database persistence for the timers, in this case persistent timers are cluster aware and only executed once in the cluster.

          • 2. Re: Scheduler service in Wildfly 9
            sumanthreddybandi

            My application has 2 clusters with 2 nodes in each cluster. Scheduler service needs to be run only once per cluster. How can we achieve HASingleton in WildFly 9?

             

            I believe i cannot use he database persistence for the timers since both cluster connect to the same database. If i use this approach, scheduler service will run only on one cluster. Please correct me if i am wrong.

            • 3. Re: Scheduler service in Wildfly 9
              wdfink

              You can try the cluster-ha-singleton quickstart, this should start a timer on one node of each cluster.

               

              The database-timers can be configured that each cluster use a different timer-storage (timer-partition) so you can separate both clusters, you might read this EJB3 Clustered Database Timers - WildFly 9