SlideShare a Scribd company logo
Using Spring Scheduler Mule
• The Spring Framework provides abstractions for asynchronous
execution and scheduling of tasks with the TaskExecutor and
TaskScheduler interfaces, respectively. Spring also features
implementations of those interfaces that support thread pools or
delegation to CommonJ within an application server environment.
Ultimately the use of these implementations behind the common
interfaces abstracts away the differences between Java SE 5, Java
SE 6 and Java EE environments.
We often get a requirement of scheduling a task or monitoring some event consistently when our
application is running on server.
In that case we need to create a thread in our application that will constantly monitor the event in
our application and start the task after every fixed interval of time.
In Mule we get plenty of options of doing it like using Quartz scheduler or Poll component etc.
But what if we want to use our custom java class for that ???
Yes, we can do a scheduling and monitoring activity using a Java class and Spring task scheduler in
our Mule application….
Let’s consider we have a simple Mule flow as following:-
Now, this is a simple flow where we will hit a url in the browser and it will send a response to the
browser and log the payload in console.
Now, we will also create a Java class here that will constantly load itself after the application run in
the server after every 10 sec and will print a message in console.
Let’s consider we our Java class is as following:-
This is a simple Java class that will log a message after every 10 seconds and will be running in our
application and will be monitoring in our application.
We can customize this class as per our requirement and put our own code here for monitoring.
So far, I have kept it simple only to demonstrate the functionality
So here is our Spring configuration in the Mule config that will trigger this class after every 10
second and keep the thread alive for monitoring and printing in the console:-
Here you can see the Spring task scheduler is scheduling the Java class after every 10 sec. Also
there is a Mule flow that will print the message in the browser and console if we hit the url
http://localhost:8082/test in browser
So if we run our application we will see the message after every 10 sec.:-
So if we hit url http://localhost:8082/test in browser we will get the following .:-
Also in the console we will get .:-
But the interesting fact is the Spring task scheduler is executing the Java class after every 10 sec. So,
using Java and Spring you can schedule and monitor events in Mule which is an alternative to Quartz
and Poll components
In my next slide I will bring some other techniques in Mule implementation .
Hope you have enjoyed this simpler version.
Keep sharing your knowledge and let our Mule community grow 

More Related Content

What's hot

Web service vm in mule
Web service vm in muleWeb service vm in mule
Web service vm in mule
Mohammed246
 
Vm component in mule demo
Vm component in mule demoVm component in mule demo
Vm component in mule demo
Sudha Ch
 
Composite source in bound and out-bound
Composite source in bound and out-boundComposite source in bound and out-bound
Composite source in bound and out-bound
Son Nguyen
 
Mule batch job
Mule batch jobMule batch job
Mule batch job
Anirban Sen Chowdhary
 
Mule with quartz
Mule with quartzMule with quartz
Mule with quartz
Anirban Sen Chowdhary
 
Mule quartz
Mule quartz Mule quartz
Mule quartz
Praneethchampion
 
Mule integration
Mule integrationMule integration
Mule integration
Son Nguyen
 
Mule esb mule message
Mule esb   mule messageMule esb   mule message
Mule esb mule message
sathyaraj Anand
 
Load balancer in mule
Load balancer in muleLoad balancer in mule
Load balancer in mule
Ramakrishna kapa
 
Mule soap
Mule soapMule soap
Mule soap
D.Rajesh Kumar
 
Quartz in Mule
Quartz in MuleQuartz in Mule
Quartz in Mule
Mohammed246
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
Khasim Cise
 
Deploying and Running in Mule
Deploying and Running in MuleDeploying and Running in Mule
Deploying and Running in Mule
Khasim Saheb
 
Soap request in mule
Soap request in mule Soap request in mule
Soap request in mule
Praneethchampion
 
Mule Microsoft Share Point 2010 Connector
Mule Microsoft Share Point 2010 ConnectorMule Microsoft Share Point 2010 Connector
Mule Microsoft Share Point 2010 Connector
Ankush Sharma
 
Scatter and gather in mule
Scatter and gather in muleScatter and gather in mule
Scatter and gather in mule
Rajkattamuri
 

What's hot (16)

Web service vm in mule
Web service vm in muleWeb service vm in mule
Web service vm in mule
 
Vm component in mule demo
Vm component in mule demoVm component in mule demo
Vm component in mule demo
 
Composite source in bound and out-bound
Composite source in bound and out-boundComposite source in bound and out-bound
Composite source in bound and out-bound
 
Mule batch job
Mule batch jobMule batch job
Mule batch job
 
Mule with quartz
Mule with quartzMule with quartz
Mule with quartz
 
Mule quartz
Mule quartz Mule quartz
Mule quartz
 
Mule integration
Mule integrationMule integration
Mule integration
 
Mule esb mule message
Mule esb   mule messageMule esb   mule message
Mule esb mule message
 
Load balancer in mule
Load balancer in muleLoad balancer in mule
Load balancer in mule
 
Mule soap
Mule soapMule soap
Mule soap
 
Quartz in Mule
Quartz in MuleQuartz in Mule
Quartz in Mule
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
 
Deploying and Running in Mule
Deploying and Running in MuleDeploying and Running in Mule
Deploying and Running in Mule
 
Soap request in mule
Soap request in mule Soap request in mule
Soap request in mule
 
Mule Microsoft Share Point 2010 Connector
Mule Microsoft Share Point 2010 ConnectorMule Microsoft Share Point 2010 Connector
Mule Microsoft Share Point 2010 Connector
 
Scatter and gather in mule
Scatter and gather in muleScatter and gather in mule
Scatter and gather in mule
 

Similar to Using spring scheduler mule

Schedule and monitor in mule
Schedule and monitor in muleSchedule and monitor in mule
Schedule and monitor in mule
Son Nguyen
 
Scheduling and monitoring with java in mule
Scheduling and monitoring with java in muleScheduling and monitoring with java in mule
Scheduling and monitoring with java in mule
Anirban Sen Chowdhary
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
Mohammed246
 
Cache for community edition
Cache for community edition Cache for community edition
Cache for community edition
javeed_mhd
 
Community edition Cache
Community edition CacheCommunity edition Cache
Community edition Cache
Praneethchampion
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
F K
 
Cache community edition
Cache community edition Cache community edition
Cache community edition
AbdulImrankhan7
 
Cache for community edition
Cache for community edition Cache for community edition
Cache for community edition
mdfkhan625
 
Cache for community edition
Cache for community edition Cache for community edition
Cache for community edition
Khasim Saheb
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
Anirban Sen Chowdhary
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
irfan1008
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
Hasan Syed
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
Sunil Komarapu
 
Running mule from java
Running mule from javaRunning mule from java
Running mule from java
Anirban Sen Chowdhary
 
Stored procedure in mule
Stored procedure in muleStored procedure in mule
Stored procedure in mule
Manav Prasad
 
A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,
Swapnil Dubey
 
Deploy with maven
Deploy with mavenDeploy with maven
Deploy with maven
Son Nguyen
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
javeed_mhd
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
Mohammed625
 
Mule stored procedure
Mule stored procedureMule stored procedure
Mule stored procedure
AbdulImrankhan7
 

Similar to Using spring scheduler mule (20)

Schedule and monitor in mule
Schedule and monitor in muleSchedule and monitor in mule
Schedule and monitor in mule
 
Scheduling and monitoring with java in mule
Scheduling and monitoring with java in muleScheduling and monitoring with java in mule
Scheduling and monitoring with java in mule
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Cache for community edition
Cache for community edition Cache for community edition
Cache for community edition
 
Community edition Cache
Community edition CacheCommunity edition Cache
Community edition Cache
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Cache community edition
Cache community edition Cache community edition
Cache community edition
 
Cache for community edition
Cache for community edition Cache for community edition
Cache for community edition
 
Cache for community edition
Cache for community edition Cache for community edition
Cache for community edition
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Running mule from java
Running mule from javaRunning mule from java
Running mule from java
 
Stored procedure in mule
Stored procedure in muleStored procedure in mule
Stored procedure in mule
 
A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,
 
Deploy with maven
Deploy with mavenDeploy with maven
Deploy with maven
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
 
Mule stored procedure
Mule stored procedureMule stored procedure
Mule stored procedure
 

More from Son Nguyen

Wsdl connector introduction
Wsdl connector introductionWsdl connector introduction
Wsdl connector introduction
Son Nguyen
 
Android intergrate with mule
Android intergrate with muleAndroid intergrate with mule
Android intergrate with mule
Son Nguyen
 
Mule flow overview
Mule flow overviewMule flow overview
Mule flow overview
Son Nguyen
 
Mule flow and filter
Mule flow and filterMule flow and filter
Mule flow and filter
Son Nguyen
 
Handle exceptions in mule
Handle exceptions in muleHandle exceptions in mule
Handle exceptions in mule
Son Nguyen
 
Spring security integrate with mule
Spring security integrate with muleSpring security integrate with mule
Spring security integrate with mule
Son Nguyen
 
Message processor in mule
Message processor in muleMessage processor in mule
Message processor in mule
Son Nguyen
 
Expression language in mule
Expression language in muleExpression language in mule
Expression language in mule
Son Nguyen
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weave
Son Nguyen
 
Batch job processing
Batch job processingBatch job processing
Batch job processing
Son Nguyen
 
Using message enricher
Using message enricherUsing message enricher
Using message enricher
Son Nguyen
 
Finance connectors with mule
Finance connectors with muleFinance connectors with mule
Finance connectors with mule
Son Nguyen
 
Google drive connection
Google drive connectionGoogle drive connection
Google drive connection
Son Nguyen
 
Using properties in mule
Using properties in muleUsing properties in mule
Using properties in mule
Son Nguyen
 
Mule integrate with microsoft
Mule integrate with microsoftMule integrate with microsoft
Mule integrate with microsoft
Son Nguyen
 
Jms queue
Jms queueJms queue
Jms queue
Son Nguyen
 
Anypoint connectors
Anypoint connectorsAnypoint connectors
Anypoint connectors
Son Nguyen
 
Mule esb basic introduction
Mule esb basic introductionMule esb basic introduction
Mule esb basic introduction
Son Nguyen
 
Runing batch job in mule
Runing batch job in muleRuning batch job in mule
Runing batch job in mule
Son Nguyen
 
Mule integration with cloud hub
Mule integration with cloud hubMule integration with cloud hub
Mule integration with cloud hub
Son Nguyen
 

More from Son Nguyen (20)

Wsdl connector introduction
Wsdl connector introductionWsdl connector introduction
Wsdl connector introduction
 
Android intergrate with mule
Android intergrate with muleAndroid intergrate with mule
Android intergrate with mule
 
Mule flow overview
Mule flow overviewMule flow overview
Mule flow overview
 
Mule flow and filter
Mule flow and filterMule flow and filter
Mule flow and filter
 
Handle exceptions in mule
Handle exceptions in muleHandle exceptions in mule
Handle exceptions in mule
 
Spring security integrate with mule
Spring security integrate with muleSpring security integrate with mule
Spring security integrate with mule
 
Message processor in mule
Message processor in muleMessage processor in mule
Message processor in mule
 
Expression language in mule
Expression language in muleExpression language in mule
Expression language in mule
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weave
 
Batch job processing
Batch job processingBatch job processing
Batch job processing
 
Using message enricher
Using message enricherUsing message enricher
Using message enricher
 
Finance connectors with mule
Finance connectors with muleFinance connectors with mule
Finance connectors with mule
 
Google drive connection
Google drive connectionGoogle drive connection
Google drive connection
 
Using properties in mule
Using properties in muleUsing properties in mule
Using properties in mule
 
Mule integrate with microsoft
Mule integrate with microsoftMule integrate with microsoft
Mule integrate with microsoft
 
Jms queue
Jms queueJms queue
Jms queue
 
Anypoint connectors
Anypoint connectorsAnypoint connectors
Anypoint connectors
 
Mule esb basic introduction
Mule esb basic introductionMule esb basic introduction
Mule esb basic introduction
 
Runing batch job in mule
Runing batch job in muleRuning batch job in mule
Runing batch job in mule
 
Mule integration with cloud hub
Mule integration with cloud hubMule integration with cloud hub
Mule integration with cloud hub
 

Recently uploaded

FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 

Using spring scheduler mule

  • 2. • The Spring Framework provides abstractions for asynchronous execution and scheduling of tasks with the TaskExecutor and TaskScheduler interfaces, respectively. Spring also features implementations of those interfaces that support thread pools or delegation to CommonJ within an application server environment. Ultimately the use of these implementations behind the common interfaces abstracts away the differences between Java SE 5, Java SE 6 and Java EE environments.
  • 3. We often get a requirement of scheduling a task or monitoring some event consistently when our application is running on server. In that case we need to create a thread in our application that will constantly monitor the event in our application and start the task after every fixed interval of time. In Mule we get plenty of options of doing it like using Quartz scheduler or Poll component etc. But what if we want to use our custom java class for that ???
  • 4. Yes, we can do a scheduling and monitoring activity using a Java class and Spring task scheduler in our Mule application….
  • 5.
  • 6. Let’s consider we have a simple Mule flow as following:- Now, this is a simple flow where we will hit a url in the browser and it will send a response to the browser and log the payload in console. Now, we will also create a Java class here that will constantly load itself after the application run in the server after every 10 sec and will print a message in console.
  • 7. Let’s consider we our Java class is as following:- This is a simple Java class that will log a message after every 10 seconds and will be running in our application and will be monitoring in our application. We can customize this class as per our requirement and put our own code here for monitoring. So far, I have kept it simple only to demonstrate the functionality
  • 8. So here is our Spring configuration in the Mule config that will trigger this class after every 10 second and keep the thread alive for monitoring and printing in the console:- Here you can see the Spring task scheduler is scheduling the Java class after every 10 sec. Also there is a Mule flow that will print the message in the browser and console if we hit the url http://localhost:8082/test in browser
  • 9. So if we run our application we will see the message after every 10 sec.:-
  • 10. So if we hit url http://localhost:8082/test in browser we will get the following .:-
  • 11. Also in the console we will get .:- But the interesting fact is the Spring task scheduler is executing the Java class after every 10 sec. So, using Java and Spring you can schedule and monitor events in Mule which is an alternative to Quartz and Poll components
  • 12. In my next slide I will bring some other techniques in Mule implementation . Hope you have enjoyed this simpler version. Keep sharing your knowledge and let our Mule community grow 