1 Reply Latest reply on Jan 13, 2004 4:50 PM by Zac Heismann

    Scheduled Tasks in JBOSS ?

    ratheeshramachandran Newbie

      Hi there

      In JBOSS, is there a way to congure a scheduled task ie. A bean or something which will be invoked at a specified frequency ?

      Thanks
      Ratheesh

        • 1. Re: Scheduled Tasks in JBOSS ?
          Zac Heismann Newbie

          Look into using a TimerMBean

          Here's an incomplete example:

          
          ArrayList al = MBeanServerFactory.findMBeanServer(null);
          server = (MBeanServer) al.get(0);
          Timer timer = new Timer();
          timerName =
           new ObjectName("ex.Timer:type=TimerService,name=ex.Cache");
          DataRefresher dataRefresher = new DataRefresher();
          
          timer.addNotificationListener(dataRefresher,null,null);
          
          timer.addNotification("ex.Timer:type=TimerService,name=ex.Cache",
           "ex.Timer:type=TimerService,name=ex.Cache",
           null,
           startDate,
           period);
          server.registerMBean(timer, timerName);
          server.invoke(timerName,"start",new Object[0],new String[0]);