[jboss-user] [Management, JMX/JBoss] - Re: An example of EJB application using JBoss Scheduler/Time

thehunt do-not-reply at jboss.com
Thu Jan 11 07:16:11 EST 2007


The Scheduler works like that:

It has a timer on which it subsribes filtered listeners. When the timer triggers, the appropriate listener catches the event and calls the predefined target class or mbean with some certain parameters. What you really want if i understood right, is to have your applications listen to the same timer events as the scheduler does. And you want to use the scheduler for that.

There are 2 solutions as i can see it.

The first one is based on being able to catch the timer events as the Scheduler itself does. This you can do by throwing away the Scheduler :) and use the Timer directly. You can set the Timer Mbean to start when jboss starts, and then your every application could implement the NotificationListener interface and subscribe to the timer through the JMX Server.

for example:
  private ObjectName mTimer;
  mTimer = new ObjectName("jboss:service=Timer");

  mListener = new YourListenerClass();
         getServer().addNotificationListener(
                 mTimer,
                 mListener,
                 new NotificationFilter(...),
                 null
         );

Check this out to see how the SchedulerManager works.
http://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/varia/scheduler/package-summary.html


The second , easiest and best solution in my opinion is to make your scheduler's target class or mbean to place messages on a durable Topic, and then have your EJB applications subscribe on this Topic. So its MDB solution :)

In order to do that, you ll have to read about the scheduler's target which can be defined in your jboss-service.xml, and how to develop a custom target (plain class or mbean). Check the JMS documentation for the Topic and how to develop topic subscribers.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4000387#4000387

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4000387



More information about the jboss-user mailing list