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
PPTX
PPTX
Scheduling torque-maui-tutorial
PPTX
Stabilising the jenga tower
PDF
NYAN Conference: Debugging asynchronous scenarios in .net
PDF
Odoo Performance Limits
PDF
Docker Workshop - Orchestrating Docker Containers
ODP
Robot Evolution
Basic example using quartz component in anypoint studio
Scheduling torque-maui-tutorial
Stabilising the jenga tower
NYAN Conference: Debugging asynchronous scenarios in .net
Odoo Performance Limits
Docker Workshop - Orchestrating Docker Containers
Robot Evolution

What's hot (20)

PDF
Structured concurrency with Kotlin Coroutines
PDF
Automated testing with Openshift
PDF
Odoo Online platform: architecture and challenges
PPTX
Introduction to Reactive Java
PDF
Structured Testing Framework
KEY
Trac/Subversion/JUnit/Maven/Jenkinsで構築する開発スタイル
PPTX
Kotlin Coroutines and Rx
PDF
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
PDF
Continuous Integration for Fun and Profit
PDF
Node.js Lab
PDF
Matthew Treinish, HP - subunit2sql: Tracking 1 Test Result in Millions, OpenS...
PDF
Andro sec rl-prototype-finalproject
PPTX
Chap3 clientsrvr
PDF
Common Workflow Language (CWL) - George Carvalho
PPTX
Reactive Java (GeeCON 2014)
PDF
Lopug docker end_of_distro
PDF
OB1K - New, Better, Faster, Devops Friendly Java container by Outbrain
PPTX
Airflow Clustering and High Availability
PPTX
Ob1k presentation at Java.IL
PDF
Structured concurrency with Kotlin Coroutines
Automated testing with Openshift
Odoo Online platform: architecture and challenges
Introduction to Reactive Java
Structured Testing Framework
Trac/Subversion/JUnit/Maven/Jenkinsで構築する開発スタイル
Kotlin Coroutines and Rx
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Continuous Integration for Fun and Profit
Node.js Lab
Matthew Treinish, HP - subunit2sql: Tracking 1 Test Result in Millions, OpenS...
Andro sec rl-prototype-finalproject
Chap3 clientsrvr
Common Workflow Language (CWL) - George Carvalho
Reactive Java (GeeCON 2014)
Lopug docker end_of_distro
OB1K - New, Better, Faster, Devops Friendly Java container by Outbrain
Airflow Clustering and High Availability
Ob1k presentation at Java.IL
Ad

Viewers also liked (7)

PPTX
使用 Quartz
PPTX
Spring Services
PPTX
Quartz in mule
PPT
Quartz.NET - Enterprise Job Scheduler for .NET Platform
PDF
Quartzでcronを範囲検索したい
PPTX
Using spring scheduler mule
PDF
White Belt DMAIC Project Line G MTTR
使用 Quartz
Spring Services
Quartz in mule
Quartz.NET - Enterprise Job Scheduler for .NET Platform
Quartzでcronを範囲検索したい
Using spring scheduler mule
White Belt DMAIC Project Line G MTTR
Ad

Similar to Quartz connector (20)

PPT
Spark Streaming Info
PDF
GDG Jakarta Meetup - Streaming Analytics With Apache Beam
PPTX
Ondemand scaling-aws
PPTX
Behind modern concurrency primitives
PPTX
Behind modern concurrency primitives
PDF
Presto anatomy
PDF
Serverless Java on Kubernetes
PPTX
Async programming and python
PPTX
Sharding and Load Balancing in Scala - Twitter's Finagle
PDF
How to execute an oracle stored procedure with nested table as a parameter fr...
PDF
Spring Web Services: SOAP vs. REST
PDF
Play Framework: async I/O with Java and Scala
PPTX
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
PPTX
[NDC 2019] Enterprise-Grade Serverless
PDF
Aplicações assíncronas no Android com
Coroutines & Jetpack
PDF
Rhebok, High Performance Rack Handler / Rubykaigi 2015
PDF
Apache Beam de A à Z
PPT
JS everywhere 2011
PDF
Load testing with Blitz
PDF
2014 09 30_sparkling_water_hands_on
Spark Streaming Info
GDG Jakarta Meetup - Streaming Analytics With Apache Beam
Ondemand scaling-aws
Behind modern concurrency primitives
Behind modern concurrency primitives
Presto anatomy
Serverless Java on Kubernetes
Async programming and python
Sharding and Load Balancing in Scala - Twitter's Finagle
How to execute an oracle stored procedure with nested table as a parameter fr...
Spring Web Services: SOAP vs. REST
Play Framework: async I/O with Java and Scala
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
Aplicações assíncronas no Android com
Coroutines & Jetpack
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Apache Beam de A à Z
JS everywhere 2011
Load testing with Blitz
2014 09 30_sparkling_water_hands_on

More from Rahul Kumar (20)

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

Recently uploaded (20)

PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
AutoCAD Professional Crack 2025 With License Key
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
iTop VPN Crack Latest Version Full Key 2025
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
wealthsignaloriginal-com-DS-text-... (1).pdf
Digital Systems & Binary Numbers (comprehensive )
AutoCAD Professional Crack 2025 With License Key
CHAPTER 2 - PM Management and IT Context
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Autodesk AutoCAD Crack Free Download 2025
Complete Guide to Website Development in Malaysia for SMEs
Wondershare Filmora 15 Crack With Activation Key [2025
Monitoring Stack: Grafana, Loki & Promtail
Design an Analysis of Algorithms II-SECS-1021-03
Patient Appointment Booking in Odoo with online payment
iTop VPN Crack Latest Version Full Key 2025
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Navsoft: AI-Powered Business Solutions & Custom Software Development
Odoo Companies in India – Driving Business Transformation.pdf
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Advanced SystemCare Ultimate Crack + Portable (2025)
Computer Software and OS of computer science of grade 11.pptx
17 Powerful Integrations Your Next-Gen MLM Software Needs

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