-
1. Re: An example of EJB application using JBoss Scheduler/Time
thehunt Jan 11, 2007 7:16 AM (in response to forumer)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. -
2. Re: An example of EJB application using JBoss Scheduler/Time
forumer Jan 11, 2007 3:43 PM (in response to forumer)Thank you very much for taking the time to reply. I am going to try to get my arms around and implement your first suggestion.
I suppose I'll register the EJB NotificationListener in the Servlet of that application. Is there a better place to do it?
Thanks again! -
3. Re: An example of EJB application using JBoss Scheduler/Time
iudoka Jan 12, 2007 12:26 AM (in response to forumer)Does this scheduler infrastructure have support for cron triggers?
-
4. Re: An example of EJB application using JBoss Scheduler/Time
dimitris Jan 12, 2007 3:57 AM (in response to forumer)Another possibility is to use the J2EE Timer Service (check the j2ee 1.4 spec).