0 Replies Latest reply on Aug 31, 2012 12:38 PM by Jonathan Fornari

    Method annotated with @Schedule doesnt work with dependency jboss.ha:service=HASingletonDeployer,type=Barrier

    Jonathan Fornari Newbie

      I have one clustered-application with 2 nodes running in jboss 6.1.0.Final.

      I have some stateless beans that need to execute some tasks at scheduled times. It is using EJB 3.1 timer service. Here is one of them:

      public class MyBean implements MyBeanLocal,
      MyBeanRemote {

      @Schedule(hour = "1", persistent = false)
      public void doStuff() { //my code }

      Until here, this works perfectly.

      But since i have 2 nodes i need the doStuff method to be executed only in one of them, so here is my META-INF/jboss.xml

      <?xml version="1.0" encoding="UTF-8"?>

      When the server starts, i see that MyBean is created in ONLY one of the nodes.

      installing bean: jboss.j2ee:ear=my-ear.ear,jar=my-jar-0.0.1-SNAPSHOT.jar,name=MyBean,service=EJB3
      with dependencies
      and demands
      -switchboard:appName=my-ear,module=my-module-0.0.1-SNAPSHOT,name=MyBean; Required: Create
      .ejb:service=EJBTimerService; Required: Described
      -injector:topLevelUnit=my-ear.ear,unit=my-jar-0.0.1-SNAPSHOT.jar,bean=MyBean; Required: Described
      .ha:service=HASingletonDeployer,type=Barrier; Required: Described
      .unit:unitName=my-ear.ear/another-jar-dao-0.0.1-SNAPSHOT.jar#my-entitymanager; Required: Described
      and supplies
      Added bean(jboss.j2ee:ear=my-ear.ear,jar=my-jar-0.0.1-SNAPSHOT.jar,name=MyBean,service=EJB3) to KernelDeployment of: my-jar-0.0.1-SNAPSHOT.jar

      But, with the dependency declared on META-INF/jboss.xml, the doStuff method is never executed. I tested removing the dependency from META-INF/jboss.xml and the method executes on the scheduled time, but it runs in the two nodes. My need is to create a scheduled method that runs in only one node of the cluster.

      Update: If i do this on META-INF/jboss.xml:

      <!-- <depends>jboss.ha:service=HASingletonDeployer,type=Barrier</depends>  -->

      The scheduled method still dont run in any of the nodes.

      But if i do this:

      <!-- <session>
      </session> -->

      The method run in the two nodes.

      Anyone can help me? Thanks.