Mule : Quartz Provider
This page last changed on Oct 27, 2006 by andrew.
Quartz provider supplies scheduling features to Mule. This provider is based on the great scheduler Quartz from OpenSymphony. The javadoc for this transport provider can be found here. And the Source Xref can be found here Quartz Connector properties
Quartz Endpoint properties
Additionally, other properties need to be set depending on the type of Job being used. The following describes the standard Mule Jobs and how to configure them. JobsMule provides a number of default Job implementations that help orchestrate scheduled events -
The following describes the configuration of each. Mule Receiver JobThis is the Job used when an inbound quartz endpoint is configured on a component. It triggers an event to be received by the component based on the endpoint configuration. A simple endpoint can be configured this way: <endpoint address="quartz:/myService"> <properties> <property name="repeatInterval" value="1000" /> <property name="payloadClassName" value="com.foo.bar.Payload" /> </properties> </endpoint> The same endpoint can also be expressed as a simple URI - <endpoint address="quartz:/myService?repeatInterval=1000&payloadClassName=com.foo.bar.Payload" />
Configuring the Payload of the EventThe payload can be set on the endpoint using the following mutually exclusive properties -
If neither of these properties are set an org.mule.providers.NullPayload will be used. Mule Delegating JobExtracts the Job object to invoke Mule Event that was dispatched to the quartz endpoint. The job can either be set as a property on The following properties can be set on the MuleEvent before the event is dispatched to quartz -
If the Job is set as the payload of the event, these properties will be ignored and the DelegatingJob will be used automatically. To explicitly configure the Delegating Job, you need to configure an outbound endpoint - <endpoint name="schedulerEndpoint" address="quartz:/myService"> <properties> <property name="jobClass" value="org.mule.providers.quartz.jobs.DelegatingJob"/> <property name="jobRef" value="com.foo.MyQuartzJob"/> <property name="repeatInterval" value="10000"/> </properties> </endpoint> Mule Client Dispatch JobCan be used to schedule a one-off or repeated message dispatch to a Mule endpoint. To Configure this Job you add an outbound endpoint with the following configuration - <endpoint name="schedulerEndpoint" address="quartz:/myService"> <properties> <property name="jobClass" value="org.mule.providers.quartz.jobs.MuleClientDispatchJob"/> <property name="jobDispatchEndpoint" value="vm://service.X"/> <property name="repeatInterval" value="10000"/> <property name="repeatCount" value="5"/> </properties> </endpoint> The additional properties set are -
The event payload dispatched with be the same event that triggered the sheduling of the job. The payload will also be the same for each execution of the job. Usually, this Job will be used for one-off execution, to delay event delivery to a later date/time. MuleClientReceiveJobIs similar to the MuleClientDispatchJob but will first perform a receive on an endpoint before doing a dispatch. The dispatch will not happen if the receive yielded null. <endpoint name="schedulerEndpoint" address="quartz:/myService"> <properties> <property name="jobClass" value="org.mule.providers.quartz.jobs.MuleClientReceiveJob"/> <property name="jobReceiveEndpoint" value="jms://queue.X"/> <property name="jobReceiveTimeout" value="10000"/> <property name="jobDispatchEndpoint" value="vm://service.X"/> <property name="repeatInterval" value="10000"/> </properties> </endpoint> The configuration is the same as for MuleClientDispatchJob except there a couple of new parameters -
Cron ExpressionsA cron endpoint can be configured this way - <endpoint address="quartz:/myService"> <properties> <property name="cronExpression" value="0 0 2 * * ?" /> .... </properties> </endpoint> The cronExpression property syntax is detailed here. Quartz Scripting ExampleHere is an example of using Quartz in conjunction with Groovy (thanks to Glenn Murry!) <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mule-configuration PUBLIC "-//SymphonySoft //DTD mule-configuration XML V1.0//EN" "http://mule.mulesource.org/dtds/mule/mule-configuration.dtd"> <mule-configuration id="Script_Sample" version="1.0"> <description> This Mule sample config shows how to use the Quartz provider to schedule a script. </description> <!-- From www.stephenpasco.com --> <global-endpoints> <endpoint name="quartz.in" address="quartz:/myService"> <properties> <property name="repeatInterval" value="2000" /> <property name="repeatCount" value="4" /> <property name="startDelay" value="3000" /> <property name="payloadClassName" value="" /> </properties> </endpoint> </global-endpoints> <model name="sample"> <mule-descriptor name="scriptRunner" implementation="org.mule.components.script.jsr223.ScriptComponent" inboundEndpoint="quartz.in"> <properties> <property name="scriptEngineName" value="groovy"/> <text-property name="scriptText"> println "Yo!" </text-property> </properties> </mule-descriptor> </model> </mule-configuration> |
Document generated by Confluence on Nov 27, 2006 10:27 |