4 Replies Latest reply on Nov 25, 2008 9:13 PM by abafna.bafna.amit.gmail.com

    How do you view Timers in the EJB3 timer service

    dozer

      Hi,


      I'm wondering how i can view scheduled asynchronous method and how can i cancel them?


      I can  create an asynchronous method without any problems as i can see the record for asynchronous method in the TIMERS table.


      But i can't figure out how to list them when I use the TimerService interface.


      I've used the resource annotation in by SLSB as shown below.



      @Resource TimerService timerService;




      And I have a method as shown below to output all the timers to the log file.  When ever i call the method the list is empty even though i can see a record in the TIMERS table in my database.



      public void showTimers(){
          for (Object obj:timerService.getTimers()){
              Timer timer = (Timer) obj;
              timer.getInfo();
              log.info(timer.getInfo());
         }
           
      }




      Does anyone know how i can list scheduled timers?
      And how can i go about cancelling them?


      Thanks

        • 1. Re: How do you view Timers in the EJB3 timer service
          zzzz8.zzzz8.netzero.net

          Hi Darrell,


          Did you ever get an answer to this question?  If so, please explain how you were able to address this issue - I'm very interested.  Thanks!

          • 2. Re: How do you view Timers in the EJB3 timer service
            dozer

            Hi,


            I didn't find an answer to this.  My interpretation of the specs suggest that the timerService.getTimers() call has to be in the enterprise bean that creates the timer. 


            In seams case it the TimerServiceDispatcher class which is part of org.jboss.seam.async package.


            In the end I just use the jmx-console to view the timers online.


            • 3. Re: How do you view Timers in the EJB3 timer service
              pieter.martin

              Halo,


              The way we did it was to save the TimerHandler in the db as a Lob,



                  @Lob
                  private TimerHandle timerHandle;



              You get the handler from timer.getHandle();


              You can then retrieve it and use it at a later stage.


              Cheers
              Pieter


              • 4. Re: How do you view Timers in the EJB3 timer service
                abafna.bafna.amit.gmail.com

                Hi Guys,


                Any one of you found out how to check, display and cancel relevant timers?


                Problem with Pieter's approach is that timer handle cannot be trusted after server restart. I keep getting NoSuchObjectLocalException when I try to cancel a scheduled timer through timer handle after server restart. Apparently, on server restart, JBoss persists all the timers again and thereby changing the timer id. Since, timer id is changed, the timer handle cannot locate the timer.


                Thanks
                Amit