4 Replies Latest reply on Nov 30, 2011 9:43 AM by Dennis Buttery

    ScheduledEventListener  onSchedule() is invoked every second

    Dennis Buttery Newbie

      Hi all,

       

         The question is:  Why?

       

         The next question is:  How do I stop that from happening?

       

         I have a schedule listener that is being invoked from a cron schedule provider.

       

         When the cron schedule fires I want to do some processing before the action pipeline takes over.

       

          The issue is that I want to do that work once and only once for each initial triggering by the cron schedule.

       

           I would have expected that the onSchedule() method would have only been called once when the cron schedule fires.

       

           Is there a config option that I overlooked?  Some other way to accomplish this?

       

      Thanks,

      -Dennis

        • 1. Re: ScheduledEventListener  onSchedule() is invoked every second
          Tom Cunningham Master

          Are you using a custom listener?  If so, can you post your example and your jboss-esb.xml?   Also what version of ESB / app-server version are you using?

          • 2. Re: ScheduledEventListener  onSchedule() is invoked every second
            Dennis Buttery Newbie

            Yes.  I have a *very* simple custom listener (for now) ...   I am using a cron schedule to wake-up every 2 minutes and fetch a file via ftp.  I want to be notified upon wakeup (once) so that I can audit/log that the fetch has started, etc...

             

            As of now, the cron trigger fires when it should and the onSchedule() method of my listener is invoked.  It is then, however, repeatedly invoked once a second until a full minute has passed by and the cron trigger is apparently no longer valid.

             

            Thanks,

            -Dennis

             

            public class MyScheduledEventListener implements ScheduledEventListener {

             

                @Override

                public void onSchedule() throws SchedulingException {

                    System.out.println("MyScheduledEventListener WAKEUP!");

                }

             

                @Override

                public void initialize(ConfigTree arg0) throws ConfigurationException {

                    // TODO Auto-generated method stub       

                }

             

                @Override

                public void uninitialize() {

                    // TODO Auto-generated method stub   

                }

             

            }

             

            In my jboss-esb.xml providers section I have:

            <schedule-provider name="CronSchedule">

                          <cron-schedule scheduleid="CronSchedule" cronExpression="* 0/2 * * * ?"/>

                      </schedule-provider>

             

            And ...  In my jboss-esb.xml service listeners I have:

            <listeners>

                             <scheduled-listener name="cron-schedule-listener" scheduleidref="CronSchedule"

                                 event-processor="MyScheduledEventListener"

                            />

                            <ftp-listener name="FTPGateway"

                                busidref="SFTPChannel"

                                is-gateway="true"

                                scheduleidref="CronSchedule"/>

                        </listeners>

            • 3. Re: ScheduledEventListener  onSchedule() is invoked every second
              Morten Hauch Newbie

              http://www.quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/crontrigger

               

              * ("all values") - used to select all values within a field. For example, "" in the minute field means *"every minute".

               

              try

              * 0/2 * * * ?

              ->

              0 0/2 * * * ?

              • 4. Re: ScheduledEventListener  onSchedule() is invoked every second
                Dennis Buttery Newbie

                Thank Morten!   That was it.  Gross oversight on my part for not examining the cron expression in more detail.

                 

                Much appreciated!