0 Replies Latest reply on Sep 13, 2005 6:31 AM by Lea Thurman

    Duplicate MBean Timer Events

    Lea Thurman Newbie

      Hi all,

      I am using JBoss-3.0.6 on Mac OS X (Tiger) with code below invoke for each message received by SLSB

      Integer eventId = (Integer)this.mBeanServer.invoke(
       this.timer.getObjectName(),
       "addNotification",
       new Object[] {
       "IDoNotKnowWhatTypeIs",
       "",
       null,
       new Date(new Date().getTime() + Timer.ONE_MINUTE),
       new Long(Timer.ONE_MINUTE),
       new Long(2)
       },
       new String[]{
       "".getClass().getName(),
       "".getClass().getName(),
       "java.lang.Object",
       Date.class.getName(),
       Long.TYPE.getName(),
       Long.TYPE.getName()
       }
      
      // Listener
      this.mbeanServer.addNotificationListener(
       this.timer.getObjectName(),
       new NotificationListener {
       private void handleNotification(Notification notification, Object callback){
       TimerNotification timerNotification = (TimerNotification)notification;
       System.out.println("Event generated using event ID " + timerNotification.getTimerID());
       }
       }
      )
      
      
      )


      For each message a new timer and a new listener are added which produce 2 events each 1 minute apart.

      It seems the events are not de-registerd since first time through I get

      Event generated using event ID 1
      Event generated using event ID 1
      (so far so good)

      Second message and

      Event generated using event ID 1
      Event generated using event ID 2
      Event generated using event ID 1
      Event generated using event ID 2

      i.e the listener is still receiving events from event id 1 event though the jmx-console only reports event 2 as active. Any ideas? Am I using the listener correctly and any thoughts on the whole approach of creating new events and listeners for each message time .. is this a robust strategy? The reason I am doing this is because I need exactly 1 min delay for each message.

      Regards
      Lea.