The Quartz transport provides support for scheduling events and for triggering new events. An inbound quartz endpoint can be used to trigger inbound events that can be repeated, such as every second. Outbound quartz endpoints can be used to schedule an existing event to fire at a later date. Users can create schedules using cron expressions, and events can be persisted in a database. \\ This transport makes use of the [Quartz Project|] at [Open Symphony|]. The Quartz site has more generic information about how to work with Quartz. \\ This transport becomes very powerful when using cron expressions to trigger events, and some of the examples below provide examples of cron expressions. If you are not familiar with cron syntax, here is a [good tutorial|]. QuartzQuartz Transport h1. Jobs Jobs are used to perform an action when a time trigger occurs from the Quartz transport. Mule provides a number of jobs for generating and scheduling events. These are detailed below. Users can also write their own jobs and hook them in using the custom-job type included with Mule. The Quartz connector is used to configure the default behavior for Quartz endpoints that reference the connector. Note if there is only one Quartz connector configured, all Quartz endpoints will use that connector. Set a property on the factory (see scheduler-ref). Provides an implementation of the Quartz Scheduler interface. If no value is provided, a scheduler is retrieved from the StdSchedulerFactory. If no properties are provided, the getDefaultScheduler method is called. Otherwise, a new factory instance is created using the given properties, and a scheduler is retrieved using the getScheduler method. An outbound Quartz endpoint allows existing events to be stored and fired at a later time/date. If you are using a persistent event store, the payload of the event must implement You configure an org.quartz.Job implementation on the endpoint to tell it what action to take. Mule has some default jobs, but you can also write your own. A Quartz inbound endpoint can be used to generate events. It is most useful when you want to trigger a service at a given interval (or cron expression) rather than have an external event trigger the service. A global endpoint that can be used as a template to create inbound and outbound Quartz endpoints. Common configuration can be set on a global endpoint and then referenced using the @ref attribute on the local endpoint. Note that because jobs sometimes only work on inbound or outbound endpoints, they have to be set on the local endpoint. Determines if the job is persistent. If so, the job detail state will be persisted for each request. More importantly, each job triggered will execute sequentially. If the Job takes longer than the next trigger the next job will wait for the current job to execute. A placeholder for Quartz jobs that can be set on the endpoint. A placeholder for Quartz jobs that can be set on inbound endpoints only. An inbound endpoint job that will trigger a new event for the service according to the schedule on the endpoint. This is useful for periodically triggering a service without the need for an external event to occur. The payload of the newly created event. The payload can be a reference to a file, fixed string, or object configured as a Spring bean. If this value is not set, an event will be generated with an org.mule.transport.NullPayload instance. An inbound endpoint job that can be used to periodically read from an external source (via another endpoint). This can be useful for triggering time-based events from sources that do not support polling or for simply controlling the rate in which events are received from the source. A reference to another configured endpoint from which events will be received. An outbound job that will schedule a job for dispatch at a later time/date. The event will get dispatched using the configured endpoint reference. The endpoint used to dispatch the scheduled event. The preferred approach is to create a global endpoint and reference it using the ref attribute. However, you can also use the address attribute to define a URI endpoint (which supports expressions). You can use the timeout attribute to specify an arbitrary time-out value associated with the endpoint that can be used by jobs that block waiting to receive events. A custom job can be configured on inbound or outbound endpoints. You can create and configure your own job implementation and use it on a Quartz endpoint. A custom job can be configured as a bean in the XML configuration and referenced using this job. The bean name or ID of the custom job to use when this job gets executed. Allows a job to be stored on the current message. This can only be used on outbound endpoints. When the message is received, the job is read and the job is added to the scheduler with the current message. This allows for custom scheduling behavior determined by the message itself. Usually the service or a transformer would create the job on the message based on application-specific logic. Any Mule-supported expressions can be used to read the job from the message. Typically, you add the job as a header, but an attachment could also be used. The base element type for all Quartz jobs The group name of the scheduled job The job group name of the scheduled job. The name to associate with the job on the endpoint. This is only really used internally when storing events. The cron expression to schedule events at specified dates/times. This attribute or repeatInterval is required. A cron expression is a string comprised by 6 or 7 fields separated by white space. Fields can contain any of the allowed values, along with various combinations of the allowed special characters for that field. The fields are as follows: {html}
Field Name MandatoryAllowed ValuesAllowed Special Chars
SecondsYES0-59, - * /
MinutesYES0-59, - * /
HoursYES0-23, - * /
Day of MonthYES1-31, - * ? / L W C
MonthYES1-12 or JAN-DEC, - * /
Day of WeekYES1-7 or SUN-SAT, - * ? / L C #
YearNOempty, 1970-2099, - * /
Cron expressions can be as simple as this: * * * * ? *
or more complex, like this: 0 0/5 14,18,3-39,52 ? JAN,MAR,SEP MON-FRI 2002-2010

Some examples:

  • 0 0 12 * * ? Fire at 12pm (noon) every day
  • 0 15 10 ? * * Fire at 10:15am every day
  • 0 15 10 * * ? Fire at 10:15am every day
  • 0 15 10 * * ? * Fire at 10:15am every day
  • 0 15 10 * * ? 2005 Fire at 10:15am every day during the year 2005
  • 0 * 14 * * ? Fire every minute starting at 2pm and ending at 2:59pm, every day
  • 0 0/5 14 * * ? Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day
The number of milliseconds between two events. This attribute or cronExpression is required. The number of events to be scheduled. This value defaults to -1, which means that the events will be scheduled indefinitely. The number of milliseconds that will elapse before the first event is fired.
Defines an endpoint reference. The preferred approach is to create a global endpoint and reference that. However, you can also use the address attribute to define a URI endpoint. A reference (name) of a global endpoint configured in your Mule instance. This is the preferred way of configuring an endpoint. A URI address string that will be used to construct a new endpoint for the Quartz endpoint to use. An arbitrary time-out value associated with the endpoint that can be used by jobs that block waiting to receive events.