4 Replies Latest reply on Aug 7, 2013 9:21 AM by freakyprogrammer

    Method annotated with @Schedule invoked twice in a singletone bean

    freakyprogrammer

      I am running my application on Jboss 7.1.1-final. I have an EJB annotated with @Singleton which has a method which is annoated with @Schedule which I use to push messsages to JMS queue at the scheduled time. But when I deploy to server scheduler is invoked twice on every interval . My Scheduler Class is here

       

       

      @Singleton
      public class SampleSch {
      
               @EJB
                private MessageProducerService messageProducerService_;
      
      
                @Schedule(minute="*/2", hour="*",second="20", persistent=false)
                public void pushMessage() {
         // emailMessage has just to,from,subject and email content which is pushed to JMS Queue   
                          messageProducerService_.pushMsgtoQueue(emailMessage);
                }
      }
      

       

      But Once server started after 2 minutes as scheduled it's invoked twice after two minutes at 20th second.

       

      15:12:20,037 INFO  [myclass] (EJB default - 7) ************ Scheduler started at *************
      15:12:20,037 INFO  [myclass] (EJB default - 7) ************ Calling pushMsgtoQueue method to put messages into the Queue *************
      15:12:20,093 INFO  myclass] (EJB default - 8) ************ Scheduler started at *************
      15:12:20,093 INFO  [myclass] (EJB default - 7) 
      push messages into Q at 2013/08/06 15:12:20   -----> First Invocation 
      
      
      15:12:20,094 INFO  [myclass] (EJB default - 8) ************ Calling pushMsgtoQueue method to put messages into the Queue *************
      15:12:20,094 INFO  [stdout] (Thread-6 (HornetQ-client-global-threads--313737904)) Not coming here
      15:12:20,095 INFO  [myclass] (Thread-6 (HornetQ-client-global-threads--313737904)) Entering into OnMessage Method
      15:12:20,209 INFO  [myclass] (EJB default - 8) 
      push messages into Q at 2013/08/06 15:12:20  -----> Second invocation
      
      
      

       

       

      How Can I resolve this?