4 Replies Latest reply on Jun 11, 2013 11:03 PM by @SumitSinghal

    Simple scheduler not working

    @SumitSinghal Level 1

      Hi,

       

      I have created the bundle and compiled the bundle but i am not able to see the logs in the log file

       

      Example

       

      import org.slf4j.Logger;

      import org.slf4j.LoggerFactory;

       

      /**

      * @scr.component

      * @scr.service interface="java.lang.Runnable"

      * @scr.property name="scheduler.expression" value="0/5 * * * * ?"

      */

      *-

      public class ScheduledCronJob implements Runnable {

           /** Default log. */  

         protected final Logger log = LoggerFactory.getLogger(ScheduledCronJob.class);    

           public void run() {    

           log.info("Executing a cron job (job#1) through the whiteboard pattern");

          }  //  }

       

      Thanks

      Sumit

        • 1. Re: Simple scheduler not working
          rush_pawan Level 4

          Hi Sumit,

           

          I hope your bundle is deployed successfully and active. Can you try to set immediate property as true so that this component will immediatly availble as soon as it deployed.

           

           

          @scr.component immediate="true" enabled="true"

           

           

           

           

          Thanks,

          Pawan

          • 2. Re: Simple scheduler not working
            @SumitSinghal Level 1

            Thanks Pawan for the reply

             

            Bundle is deployed successfully and active .

            I tried with

            @scr.component immediate="true" enabled="true" but still its not working.Logs are not created.

             

            Thanks

            Sumit


            • 3. Re: Simple scheduler not working
              rush_pawan Level 4

              Hi Sumit,

               

              I tried this and its perfactly works in my local. can you use below and try

               

              import org.slf4j.Logger;

              import org.slf4j.LoggerFactory;

              import org.apache.felix.scr.annotations.Component;

              import org.apache.felix.scr.annotations.Properties;

              import org.apache.felix.scr.annotations.Property;

              import org.apache.felix.scr.annotations.Service;

               

               

              @Component

              @Service(value = Runnable.class)

              @Properties({

              @Property(name="scheduler.expression", value="0/5 * * * * ?")})

               

               

              public class SchedulerTest implements Runnable {

                   /** Default log. */ 

                 protected final Logger log = LoggerFactory.getLogger(SchedulerTest.class);   

                 @Override 

                 public void run() {   

                   log.info("Executing a cron job (job#1) through the whiteboard pattern");

                  } 

              }

               

              Also watch the log for deployment status of bundle and activation.

               

              Thanks,

              Pawan

              • 4. Re: Simple scheduler not working
                @SumitSinghal Level 1

                thanks pawan now its working