JBoss.org Community Documentation

Chapter 17. Quartz scheduler integration

JBossAS comes bundled with Quartz integration packaged as a JCA Message-Inflow resource adapter quartz-ra.rar. This integration allows you to schedule stateless or stateful quartz jobs and have the job be posted to a Message Driven bean. The Quartz Resource Adapter creates a non-persistent scheduler. Jobs are created from the information in the MDB's activation config spec.


Currently only cron jobs are allowed to be configured.

Take a look at the org.jboss.tutorial.jca_inflow_quartz.bean.AnnotatedQuartzMDBBean:

@MessageDriven(activationConfig =
{@ActivationConfigProperty(propertyName = "cronTrigger", propertyValue = "0/2 * * * * ?")})
public class AnnotatedQuartzMDBBean implements Job

This is a simple MDB that implements the org.quartz.Job interface. The cronTrigger activation spec attribute is required. In this you specify a cron syntax as documented in the Quartz documentation. The @org.jboss.ejb3.annotation.ResourceAdapter annotation is used to tell the EJB container which resource adapter to use for the inflow implementation.

Using deployment descriptors :

Instead of using annotations, you can also use a deployment descriptor to configure the MDB for Quartz integration. Take a look at META-INF/ejb-jar.xml and META-INF/jboss.xml The ejb-jar.xml configures the cronTrigger through the <activation-config> element:

         <activation-config-property-value>0/2 * * * * ?</activation-config-property-value>


The jboss.xml configures the resource-adapter-name :


Building and Running

From the command prompt, move to the "jca_inflow_quartz" folder under the Section 1.3, “Set the EJB3_TUTORIAL_HOME”

Ant Users:

Make sure the "default" server configuration of JBossAS-5.x is running

$ ant

This will deploy the jar into the JBossAS-5.x server ("default" configuration).

Maven Users: Make sure the AS is not running.

$ mvn clean install -PRunSingleTutorial

This will create the jar in the target folder of the tutorial. Copy this jar to the deploy folder of JBossAS-5.x

On the server side when the application is deployed, you will notice these logs:

18:46:57,053 INFO  [QuartzMDBBean] ************** JOB: job.4.1232457416127
18:46:58,023 INFO  [AnnotatedQuartzMDBBean] ************** here in annotated!!!!
18:46:58,026 INFO  [QuartzMDBBean] ************** JOB: job.2.1232457416077
18:47:00,019 INFO  [AnnotatedQuartzMDBBean] ************** here in annotated!!!!
18:47:00,021 INFO  [QuartzMDBBean] ************** JOB: job.2.1232457416077
18:47:00,023 INFO  [QuartzMDBBean] ************** JOB: job.4.1232457416127
18:47:02,020 INFO  [AnnotatedQuartzMDBBean] ************** here in annotated!!!!
18:47:02,023 INFO  [QuartzMDBBean] ************** JOB: job.2.1232457416077
18:47:03,019 INFO  [QuartzMDBBean] ************** JOB: job.4.1232457416127
18:47:04,022 INFO  [AnnotatedQuartzMDBBean] ************** here in annotated!!!!
18:47:04,024 INFO  [QuartzMDBBean] ************** JOB: job.2.1232457416077
18:47:06,019 INFO  [AnnotatedQuartzMDBBean] ************** here in annotated!!!!
18:47:06,021 INFO  [QuartzMDBBean] ************** JOB: job.2.1232457416077
18:47:06,024 INFO  [QuartzMDBBean] ************** JOB: job.4.1232457416127
18:47:08,019 INFO  [AnnotatedQuartzMDBBean] ************** here in annotated!!!!
18:47:08,021 INFO  [QuartzMDBBean] ************** JOB: job.2.1232457416077
18:47:09,020 INFO  [QuartzMDBBean] ************** JOB: job.4.1232457416127