SlideShare a Scribd company logo
Using Quartz Connector
By Rahul Kumar
Prerequisites
Understanding of basic endpoints like http, file etc
Example : http://localhost:8081/app/b
file:///D/invoice/input
Understanding of CRON expressions
A good place to learn CRON expressions is
http://www.quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/crontrigger.html
Quartz Connector
The Quartz Connector supports the scheduling of programmatic events, both inside and outside your Mule
flow. Through a quartz endpoint, you can trigger flows that don’t depend on receiving any external input to
execute at scheduled times.
For instance, an inbound Quartz endpoint can trigger inbound events, such as temperature reports from a
remote location, at regular intervals.
Outbound Quartz endpoints can delay otherwise imminent events. For example, you can prevent outgoing
email from being sent as soon as it has completed processing in your Mule flow. Instead, you can use
Quartz to delay sending it until the top of the next hour.
Inbound Quartz Endpoint
A Quartz inbound endpoint can be used to generate events. It is most useful when you want to trigger a
flow at a given interval (or cron expression) rather than have an external event trigger the flow.
Polling
Creating custom events
Polling with Quartz
The below Quartz endpoint polls for files using the “File” endpoint. It polls every 10 seconds starting at
12:15:00 PM everyday till 12:15:50 PM
<file:endpoint name="File" path="./src/main/resources/input" responseTimeout="10000"
doc:name="File"/>
<flow name="quartz-polling-with-incomingfile-in-folder">
<quartz:inbound-endpoint jobName="FilePollingJob" cronExpression="0/10 15 12 * * ?"
responseTimeout="10000" doc:name="Quartz" connector-ref="Quartz" repeatInterval="0">
<quartz:endpoint-polling-job>
<quartz:job-endpoint ref="File"/>
</quartz:endpoint-polling-job>
</quartz:inbound-endpoint>
</flow>
Example 2
The below Quartz endpoint executes a HTTP GET request to http://localhost:8081/app/b every 30
seconds starting at 11:05:00 AM till 11:05:30 AM
<flow name="quartz-polling-with-http-get-invoke">
<quartz:inbound-endpoint jobName="HTTPPollingJob" cronExpression="0/30 5 11 * * ?" connector-ref="Quartz"
responseTimeout="10000" doc:name="Quartz" repeatInterval="0">
<quartz:endpoint-polling-job>
<quartz:job-endpoint address="http://localhost:8081/app/b"/>
</quartz:endpoint-polling-job>
</quartz:inbound-endpoint>
</flow>
Generate Events with Quartz
The below Quartz endpoint creates an event which will post Payload “Event from Quartz !! ” every 10
seconds starting at 01:36:00 PM till 01:36:50 PM
<flow name="app7-3Flow1">
<quartz:inbound-endpoint jobName="SimpleEventCreateJob" cronExpression="0/10 36 13 * * ?" repeatInterval="0"
responseTimeout="10000" doc:name="Quartz">
<quartz:event-generator-job>
<quartz:payload>Event from Quartz !! </quartz:payload>
</quartz:event-generator-job>
</quartz:inbound-endpoint>
</flow>
Outbound Quartz Endpoint
An outbound Quartz endpoint allows existing events to be stored and fired at a later time/date.
Dispatching events
Dispatching custom events
Dispatching events with Quartz
Example 1
The below Quartz endpoint Invokes the job endpoint which is file i.e creates file several times according to
CRON expression that is starting at 01:43 PM at interval of 10 seconds till 01:43:50 PM
<file:endpoint path="./src/main/resources/output" name="File-Outbound-Endpoint" responseTimeout="10000"
doc:name="File"/> <flow name="quartz-schedule-dispatch-file">
<http:listener config-ref="HTTP_Listener_Configuration" path="/app/c" doc:name="HTTP"/>
<set-payload value="#['Payload for Dispatch !']" doc:name="Set Payload"/>
<quartz:outbound-endpoint jobName="FileDispatchJob" cronExpression="0/10 43 13 * * ?" connector-ref="Quartz"
responseTimeout="10000" doc:name="Quartz">
<quartz:scheduled-dispatch-job>
<quartz:job-endpoint ref="File-Outbound-Endpoint"/>
</quartz:scheduled-dispatch-job>
</quartz:outbound-endpoint>
</flow>
Custom Quartz Job
We can write our own Quartz job by implementing the org.quartz.Job
interface, this allows us to leverage Java to dispatch an event at the
scheduled time
Override the public void execute(JobExecutionContext
jobExecutionContext) throws JobExecutionException; - to define what
should happen when the job fires.
Need to give source in evaluator and name of the created java class in the
expression. This will trigger the execute() function of that class at the cron
specified time.
Example of Custom Quartz Job:
package org.rahul.quartz.job;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class CustomQuartzJob implements org.quartz.Job{
private String data;
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
try {
FileOutputStream fos = new FileOutputStream("D:AnypointStudio-
5.4.3Workspaceapp7srcmainresourcesoutputoutput.txt");
fos.write(this.data.getBytes());
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
We have to pass an instance of the created Quartz job and supply it to the Quartz endpoint as evaluator and the fully qualified name
of the created Quartz Job in the expression field. For this example i have passed evaluator from the Payload.
Example Snippet below:
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
{
data: "Hello from Quartz!!"
} as :object {
class : "org.rahul.quartz.job.CustomQuartzJob"
}]]></dw:set-payload>
</dw:transform-message>
<quartz:outbound-endpoint jobName="customJob1" responseTimeout="10000" doc:name="Quartz" cronExpression="0/10 29 12
* * ?">
<quartz:custom-job-from-message evaluator="payload" expression="org.rahul.quartz.job.CustomQuartzJob" />
</quartz:outbound-endpoint>
References
https://docs.mulesoft.com/mule-user-guide/v/3.6/quartz-connector
https://docs.mulesoft.com/mule-user-guide/v/3.7/quartz-transport-reference

More Related Content

PPTX
Basic example using quartz component in anypoint studio
prudhvivreddy
 
PPTX
Sge
Chris Roeder
 
PPTX
Scheduling torque-maui-tutorial
Santosh Kumar
 
PPTX
Stabilising the jenga tower
Gordon Chung
 
PDF
NYAN Conference: Debugging asynchronous scenarios in .net
Alexandra Hayere
 
PDF
Odoo Performance Limits
Odoo
 
PDF
Docker Workshop - Orchestrating Docker Containers
Hugo Henley
 
ODP
Robot Evolution
Oleg Popov
 
Basic example using quartz component in anypoint studio
prudhvivreddy
 
Scheduling torque-maui-tutorial
Santosh Kumar
 
Stabilising the jenga tower
Gordon Chung
 
NYAN Conference: Debugging asynchronous scenarios in .net
Alexandra Hayere
 
Odoo Performance Limits
Odoo
 
Docker Workshop - Orchestrating Docker Containers
Hugo Henley
 
Robot Evolution
Oleg Popov
 

What's hot (20)

PDF
Structured concurrency with Kotlin Coroutines
Vadims Savjolovs
 
PDF
Automated testing with Openshift
Oleg Popov
 
PDF
Odoo Online platform: architecture and challenges
Odoo
 
PPTX
Introduction to Reactive Java
Tomasz Kowalczewski
 
PDF
Structured Testing Framework
serzar
 
KEY
Trac/Subversion/JUnit/Maven/Jenkinsで構築する開発スタイル
Shuji Watanabe
 
PPTX
Kotlin Coroutines and Rx
Shaul Rosenzwieg
 
PDF
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Badoo Development
 
PDF
Continuous Integration for Fun and Profit
inovex GmbH
 
PDF
Node.js Lab
Leo Nguyen
 
PDF
Matthew Treinish, HP - subunit2sql: Tracking 1 Test Result in Millions, OpenS...
Cloud Native Day Tel Aviv
 
PDF
Andro sec rl-prototype-finalproject
LiadBercovich
 
PPTX
Chap3 clientsrvr
Rachid Lajouad
 
PDF
Common Workflow Language (CWL) - George Carvalho
George Carvalho
 
PPTX
Reactive Java (GeeCON 2014)
Tomasz Kowalczewski
 
PDF
Lopug docker end_of_distro
Chris Swan
 
PDF
OB1K - New, Better, Faster, Devops Friendly Java container by Outbrain
Eran Harel
 
PPTX
Airflow Clustering and High Availability
Robert Sanders
 
PPTX
Ob1k presentation at Java.IL
Eran Harel
 
PDF
JavaCro'15 - Spring @Async - Dragan Juričić
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Structured concurrency with Kotlin Coroutines
Vadims Savjolovs
 
Automated testing with Openshift
Oleg Popov
 
Odoo Online platform: architecture and challenges
Odoo
 
Introduction to Reactive Java
Tomasz Kowalczewski
 
Structured Testing Framework
serzar
 
Trac/Subversion/JUnit/Maven/Jenkinsで構築する開発スタイル
Shuji Watanabe
 
Kotlin Coroutines and Rx
Shaul Rosenzwieg
 
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Badoo Development
 
Continuous Integration for Fun and Profit
inovex GmbH
 
Node.js Lab
Leo Nguyen
 
Matthew Treinish, HP - subunit2sql: Tracking 1 Test Result in Millions, OpenS...
Cloud Native Day Tel Aviv
 
Andro sec rl-prototype-finalproject
LiadBercovich
 
Chap3 clientsrvr
Rachid Lajouad
 
Common Workflow Language (CWL) - George Carvalho
George Carvalho
 
Reactive Java (GeeCON 2014)
Tomasz Kowalczewski
 
Lopug docker end_of_distro
Chris Swan
 
OB1K - New, Better, Faster, Devops Friendly Java container by Outbrain
Eran Harel
 
Airflow Clustering and High Availability
Robert Sanders
 
Ob1k presentation at Java.IL
Eran Harel
 
Ad

Viewers also liked (7)

PPTX
使用 Quartz
Gelis Wu
 
PPTX
Spring Services
Kasun Madusanke
 
PPTX
Quartz in mule
Manav Prasad
 
PPT
Quartz.NET - Enterprise Job Scheduler for .NET Platform
Guo Albert
 
PDF
Quartzでcronを範囲検索したい
chibochibo
 
PPTX
Using spring scheduler mule
Son Nguyen
 
PDF
White Belt DMAIC Project Line G MTTR
Irfan Rasheed Rana
 
使用 Quartz
Gelis Wu
 
Spring Services
Kasun Madusanke
 
Quartz in mule
Manav Prasad
 
Quartz.NET - Enterprise Job Scheduler for .NET Platform
Guo Albert
 
Quartzでcronを範囲検索したい
chibochibo
 
Using spring scheduler mule
Son Nguyen
 
White Belt DMAIC Project Line G MTTR
Irfan Rasheed Rana
 
Ad

Similar to Quartz connector (20)

PPT
Spark Streaming Info
Doug Chang
 
PDF
GDG Jakarta Meetup - Streaming Analytics With Apache Beam
Imre Nagi
 
PPTX
Ondemand scaling-aws
Iegor Fadieiev
 
PPTX
Behind modern concurrency primitives
Bartosz Sypytkowski
 
PPTX
Behind modern concurrency primitives
Bartosz Sypytkowski
 
PDF
Presto anatomy
Dongmin Yu
 
PDF
Serverless Java on Kubernetes
Krzysztof Sobkowiak
 
PPTX
Async programming and python
Chetan Giridhar
 
PPTX
Sharding and Load Balancing in Scala - Twitter's Finagle
Geoff Ballinger
 
PDF
How to execute an oracle stored procedure with nested table as a parameter fr...
Priyobroto Ghosh (Mule ESB Certified)
 
PDF
Spring Web Services: SOAP vs. REST
Sam Brannen
 
PDF
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
 
PPTX
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
KatyShimizu
 
PPTX
[NDC 2019] Enterprise-Grade Serverless
KatyShimizu
 
PDF
Aplicações assíncronas no Android com
Coroutines & Jetpack
Nelson Glauber Leal
 
PDF
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Masahiro Nagano
 
PDF
Apache Beam de A à Z
Paris Data Engineers !
 
PPT
JS everywhere 2011
Oleg Podsechin
 
PDF
Load testing with Blitz
Lindsay Holmwood
 
PDF
2014 09 30_sparkling_water_hands_on
Sri Ambati
 
Spark Streaming Info
Doug Chang
 
GDG Jakarta Meetup - Streaming Analytics With Apache Beam
Imre Nagi
 
Ondemand scaling-aws
Iegor Fadieiev
 
Behind modern concurrency primitives
Bartosz Sypytkowski
 
Behind modern concurrency primitives
Bartosz Sypytkowski
 
Presto anatomy
Dongmin Yu
 
Serverless Java on Kubernetes
Krzysztof Sobkowiak
 
Async programming and python
Chetan Giridhar
 
Sharding and Load Balancing in Scala - Twitter's Finagle
Geoff Ballinger
 
How to execute an oracle stored procedure with nested table as a parameter fr...
Priyobroto Ghosh (Mule ESB Certified)
 
Spring Web Services: SOAP vs. REST
Sam Brannen
 
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
KatyShimizu
 
[NDC 2019] Enterprise-Grade Serverless
KatyShimizu
 
Aplicações assíncronas no Android com
Coroutines & Jetpack
Nelson Glauber Leal
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Masahiro Nagano
 
Apache Beam de A à Z
Paris Data Engineers !
 
JS everywhere 2011
Oleg Podsechin
 
Load testing with Blitz
Lindsay Holmwood
 
2014 09 30_sparkling_water_hands_on
Sri Ambati
 

More from Rahul Kumar (20)

PPTX
Combine collections transformer
Rahul Kumar
 
PPTX
Creating global functions
Rahul Kumar
 
PPTX
Creating custom object store
Rahul Kumar
 
PPTX
Using parse template component
Rahul Kumar
 
PPTX
Using groovy component
Rahul Kumar
 
PPTX
Using expression component
Rahul Kumar
 
PPTX
Creating custom transformer
Rahul Kumar
 
PPTX
Creating custom aggregation strategy
Rahul Kumar
 
PPTX
Creating custom aggregator
Rahul Kumar
 
PPTX
Byte array to hex string transformer
Rahul Kumar
 
PPTX
Creating custom filter
Rahul Kumar
 
PPTX
Hex string to byte array transformer
Rahul Kumar
 
PPTX
XML to DOM Transformer
Rahul Kumar
 
PPTX
Dom to xml transformer
Rahul Kumar
 
PPTX
Object to input stream transformer
Rahul Kumar
 
PPTX
Byte array to object transformer
Rahul Kumar
 
PPTX
Byte array to string transformer
Rahul Kumar
 
PPTX
Object to string transformer
Rahul Kumar
 
PPTX
Csv to json transform in simple steps
Rahul Kumar
 
PPTX
Using scatter gather
Rahul Kumar
 
Combine collections transformer
Rahul Kumar
 
Creating global functions
Rahul Kumar
 
Creating custom object store
Rahul Kumar
 
Using parse template component
Rahul Kumar
 
Using groovy component
Rahul Kumar
 
Using expression component
Rahul Kumar
 
Creating custom transformer
Rahul Kumar
 
Creating custom aggregation strategy
Rahul Kumar
 
Creating custom aggregator
Rahul Kumar
 
Byte array to hex string transformer
Rahul Kumar
 
Creating custom filter
Rahul Kumar
 
Hex string to byte array transformer
Rahul Kumar
 
XML to DOM Transformer
Rahul Kumar
 
Dom to xml transformer
Rahul Kumar
 
Object to input stream transformer
Rahul Kumar
 
Byte array to object transformer
Rahul Kumar
 
Byte array to string transformer
Rahul Kumar
 
Object to string transformer
Rahul Kumar
 
Csv to json transform in simple steps
Rahul Kumar
 
Using scatter gather
Rahul Kumar
 

Recently uploaded (20)

DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PPTX
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PPTX
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PDF
Immersive experiences: what Pharo users do!
ESUG
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
Activate_Methodology_Summary presentatio
annapureddyn
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
Immersive experiences: what Pharo users do!
ESUG
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 

Quartz connector

  • 2. Prerequisites Understanding of basic endpoints like http, file etc Example : http://localhost:8081/app/b file:///D/invoice/input Understanding of CRON expressions A good place to learn CRON expressions is http://www.quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/crontrigger.html
  • 3. Quartz Connector The Quartz Connector supports the scheduling of programmatic events, both inside and outside your Mule flow. Through a quartz endpoint, you can trigger flows that don’t depend on receiving any external input to execute at scheduled times. For instance, an inbound Quartz endpoint can trigger inbound events, such as temperature reports from a remote location, at regular intervals. Outbound Quartz endpoints can delay otherwise imminent events. For example, you can prevent outgoing email from being sent as soon as it has completed processing in your Mule flow. Instead, you can use Quartz to delay sending it until the top of the next hour.
  • 4. Inbound Quartz Endpoint A Quartz inbound endpoint can be used to generate events. It is most useful when you want to trigger a flow at a given interval (or cron expression) rather than have an external event trigger the flow. Polling Creating custom events
  • 5. Polling with Quartz The below Quartz endpoint polls for files using the “File” endpoint. It polls every 10 seconds starting at 12:15:00 PM everyday till 12:15:50 PM <file:endpoint name="File" path="./src/main/resources/input" responseTimeout="10000" doc:name="File"/> <flow name="quartz-polling-with-incomingfile-in-folder"> <quartz:inbound-endpoint jobName="FilePollingJob" cronExpression="0/10 15 12 * * ?" responseTimeout="10000" doc:name="Quartz" connector-ref="Quartz" repeatInterval="0"> <quartz:endpoint-polling-job> <quartz:job-endpoint ref="File"/> </quartz:endpoint-polling-job> </quartz:inbound-endpoint> </flow>
  • 6. Example 2 The below Quartz endpoint executes a HTTP GET request to http://localhost:8081/app/b every 30 seconds starting at 11:05:00 AM till 11:05:30 AM <flow name="quartz-polling-with-http-get-invoke"> <quartz:inbound-endpoint jobName="HTTPPollingJob" cronExpression="0/30 5 11 * * ?" connector-ref="Quartz" responseTimeout="10000" doc:name="Quartz" repeatInterval="0"> <quartz:endpoint-polling-job> <quartz:job-endpoint address="http://localhost:8081/app/b"/> </quartz:endpoint-polling-job> </quartz:inbound-endpoint> </flow>
  • 7. Generate Events with Quartz The below Quartz endpoint creates an event which will post Payload “Event from Quartz !! ” every 10 seconds starting at 01:36:00 PM till 01:36:50 PM <flow name="app7-3Flow1"> <quartz:inbound-endpoint jobName="SimpleEventCreateJob" cronExpression="0/10 36 13 * * ?" repeatInterval="0" responseTimeout="10000" doc:name="Quartz"> <quartz:event-generator-job> <quartz:payload>Event from Quartz !! </quartz:payload> </quartz:event-generator-job> </quartz:inbound-endpoint> </flow>
  • 8. Outbound Quartz Endpoint An outbound Quartz endpoint allows existing events to be stored and fired at a later time/date. Dispatching events Dispatching custom events
  • 9. Dispatching events with Quartz Example 1 The below Quartz endpoint Invokes the job endpoint which is file i.e creates file several times according to CRON expression that is starting at 01:43 PM at interval of 10 seconds till 01:43:50 PM <file:endpoint path="./src/main/resources/output" name="File-Outbound-Endpoint" responseTimeout="10000" doc:name="File"/> <flow name="quartz-schedule-dispatch-file"> <http:listener config-ref="HTTP_Listener_Configuration" path="/app/c" doc:name="HTTP"/> <set-payload value="#['Payload for Dispatch !']" doc:name="Set Payload"/> <quartz:outbound-endpoint jobName="FileDispatchJob" cronExpression="0/10 43 13 * * ?" connector-ref="Quartz" responseTimeout="10000" doc:name="Quartz"> <quartz:scheduled-dispatch-job> <quartz:job-endpoint ref="File-Outbound-Endpoint"/> </quartz:scheduled-dispatch-job> </quartz:outbound-endpoint> </flow>
  • 10. Custom Quartz Job We can write our own Quartz job by implementing the org.quartz.Job interface, this allows us to leverage Java to dispatch an event at the scheduled time Override the public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException; - to define what should happen when the job fires. Need to give source in evaluator and name of the created java class in the expression. This will trigger the execute() function of that class at the cron specified time.
  • 11. Example of Custom Quartz Job: package org.rahul.quartz.job; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; public class CustomQuartzJob implements org.quartz.Job{ private String data; public String getData() { return data; } public void setData(String data) { this.data = data; } @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { try { FileOutputStream fos = new FileOutputStream("D:AnypointStudio- 5.4.3Workspaceapp7srcmainresourcesoutputoutput.txt"); fos.write(this.data.getBytes()); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
  • 12. We have to pass an instance of the created Quartz job and supply it to the Quartz endpoint as evaluator and the fully qualified name of the created Quartz Job in the expression field. For this example i have passed evaluator from the Payload. Example Snippet below: <dw:transform-message doc:name="Transform Message"> <dw:set-payload><![CDATA[%dw 1.0 %output application/java --- { data: "Hello from Quartz!!" } as :object { class : "org.rahul.quartz.job.CustomQuartzJob" }]]></dw:set-payload> </dw:transform-message> <quartz:outbound-endpoint jobName="customJob1" responseTimeout="10000" doc:name="Quartz" cronExpression="0/10 29 12 * * ?"> <quartz:custom-job-from-message evaluator="payload" expression="org.rahul.quartz.job.CustomQuartzJob" /> </quartz:outbound-endpoint>

Editor's Notes

  • #3: Understanding of basic endpoints like http, file etc Example : http://localhost:8081/app/b file:///D/invoice/input Understanding of CRON expressions A good place to learn CRON expressions is http://www.quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/crontrigger.html
  • #4: The Quartz Connector supports the scheduling of programmatic events, both inside and outside your Mule flow. Through a quartz endpoint, you can trigger flows that don’t depend on receiving any external input to execute at scheduled times. For instance, an inbound Quartz endpoint can trigger inbound events, such as temperature reports from a remote location, at regular intervals. Outbound Quartz endpoints can delay otherwise imminent events. For example, you can prevent outgoing email from being sent as soon as it has completed processing in your Mule flow. Instead, you can use Quartz to delay sending it until the top of the next hour.
  • #5: A Quartz inbound endpoint can be used to generate events. It is most useful when you want to trigger a flow at a given interval (or cron expression) rather than have an external event trigger the flow. Polling Creating custom events
  • #6: The below Quartz endpoint polls for files using the “File” endpoint. It polls every 10 seconds starting at 12:15:00 PM everyday till 12:15:50 PM <file:endpoint name="File" path="./src/main/resources/input" responseTimeout="10000" doc:name="File"/> <flow name="quartz-polling-with-incomingfile-in-folder"> <quartz:inbound-endpoint jobName="FilePollingJob" cronExpression="0/10 15 12 * * ?" responseTimeout="10000" doc:name="Quartz" connector-ref="Quartz" repeatInterval="0"> <quartz:endpoint-polling-job> <quartz:job-endpoint ref="File"/> </quartz:endpoint-polling-job> </quartz:inbound-endpoint> </flow>
  • #7: Example 2 The below Quartz endpoint executes a HTTP GET request to http://localhost:8081/app/b every 30 seconds starting at 11:05:00 AM till 11:05:30 AM <flow name="quartz-polling-with-http-get-invoke"> <quartz:inbound-endpoint jobName="HTTPPollingJob" cronExpression="0/30 5 11 * * ?" connector-ref="Quartz" responseTimeout="10000" doc:name="Quartz" repeatInterval="0"> <quartz:endpoint-polling-job> <quartz:job-endpoint address="http://localhost:8081/app/b"/> </quartz:endpoint-polling-job> </quartz:inbound-endpoint> </flow>
  • #8: The below Quartz endpoint creates an event which will post Payload “Event from Quartz !! ” every 10 seconds starting at 01:36:00 PM till 01:36:50 PM <flow name="app7-3Flow1"> <quartz:inbound-endpoint jobName="SimpleEventCreateJob" cronExpression="0/10 36 13 * * ?" repeatInterval="0" responseTimeout="10000" doc:name="Quartz"> <quartz:event-generator-job> <quartz:payload>Event from Quartz !! </quartz:payload> </quartz:event-generator-job> </quartz:inbound-endpoint> </flow>
  • #9: An outbound Quartz endpoint allows existing events to be stored and fired at a later time/date. Dispatching events Dispatching custom events
  • #10: Example 1 The below Quartz endpoint Invokes the job endpoint which is file i.e creates file several times according to CRON expression that is starting at 01:43 PM at interval of 10 seconds till 01:43:50 PM <file:endpoint path="./src/main/resources/output" name="File-Outbound-Endpoint" responseTimeout="10000" doc:name="File"/> <flow name="quartz-schedule-dispatch-file"> <http:listener config-ref="HTTP_Listener_Configuration" path="/app/c" doc:name="HTTP"/> <set-payload value="#['Payload for Dispatch !']" doc:name="Set Payload"/> <quartz:outbound-endpoint jobName="FileDispatchJob" cronExpression="0/10 43 13 * * ?" connector-ref="Quartz" responseTimeout="10000" doc:name="Quartz"> <quartz:scheduled-dispatch-job> <quartz:job-endpoint ref="File-Outbound-Endpoint"/> </quartz:scheduled-dispatch-job> </quartz:outbound-endpoint> </flow>
  • #11: We can write our own Quartz job by implementing the org.quartz.Job interface, this allows us to leverage Java to dispatch an event at the scheduled time Override the public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException; - to define what should happen when the job fires. Need to give source in evaluator and name of the created java class in the expression. This will trigger the execute() function of that class at the cron specified time.
  • #12: Example of Custom Quartz Job: package org.rahul.quartz.job; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; public class CustomQuartzJob implements org.quartz.Job{ private String data; public String getData() { return data; } public void setData(String data) { this.data = data; } @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { try { FileOutputStream fos = new FileOutputStream("D:\\AnypointStudio-5.4.3\\Workspace\\app7\\src\\main\\resources\\output\\output.txt"); fos.write(this.data.getBytes()); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
  • #13: We have to pass an instance of the created Quartz job and supply it to the Quartz endpoint as evaluator and the fully qualified name of the created Quartz Job in the expression field. For this example i have passed evaluator from the Payload. Example Snippet below: <dw:transform-message doc:name="Transform Message"> <dw:set-payload><![CDATA[%dw 1.0 %output application/java --- { data: "Hello from Quartz!!" } as :object { class : "org.rahul.quartz.job.CustomQuartzJob" }]]></dw:set-payload> </dw:transform-message> <quartz:outbound-endpoint jobName="customJob1" responseTimeout="10000" doc:name="Quartz" cronExpression="0/10 29 12 * * ?"> <quartz:custom-job-from-message evaluator="payload" expression="org.rahul.quartz.job.CustomQuartzJob" /> </quartz:outbound-endpoint>
  • #14: https://docs.mulesoft.com/mule-user-guide/v/3.6/quartz-connector https://docs.mulesoft.com/mule-user-guide/v/3.7/quartz-transport-reference