[jboss-user] [EJB 3.0] - Re: Using quartz from EJB 3.0

henk53 do-not-reply at jboss.com
Fri Jul 18 13:22:07 EDT 2008


"jaikiran" wrote : So, is there any specific reason for injecting (or even try to lookup) the scheduler from JNDI? Why not just use the Quartz scheduler APIs to trigger the jobs?

Well, using Quartz directly in the EJB3 container is illegal. The EJB3 container prohibits code to spawn its own threads. Spawning threads is exactly what Quartz does.

Normally, in Java SE code or within a web application, you would simply use a code fragment like below to obtain the scheduler:


  | SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
  | Scheduler scheduler = schedFact.getScheduler();
  | 

However, doing something like this in e.g. a stateless session bean is illegal and would mess up the container.

"wolfc" wrote : There are two ways to use Quartz from EJB3:
  | 1. the unsupported EJB3 Quartz timer service: https://jira.jboss.org/jira/browse/EJBTHREE-619
  | 2. or the Quartz resource adapter: http://wiki.jboss.org/auth/wiki/QuartzSchedulerIntegration
  | 

I already tried the second option. The Quartz resource adapter appears to be strictly an inflow adapter. It seems to be able to replace something like jobs.xml in Quartz. I.e. it reads the annotations from classes (and probably also from the EJB3 deployment descriptor) and statically schedules jobs based on that. 

Based on what I tried and read so far, the resource adapter does not seem to work the other way around: my code can't control quartz. Instead, using the RA quartz can only control my code. I may be wrong though. I already asked for this specifically in the JCA forum but haven't received any replies yet.

I'm definitively going to check out the "unsupported EJB3 Quartz timer service", although 'unsupported' doesn't sound too good. Thanks for the suggestion! :)

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

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



More information about the jboss-user mailing list