Add and Configure Scheduler in Mule4

Scheduler Endpoint (Trigger)

The Scheduler component enables you to trigger a flow when a time-based condition is met. Read more.

You can add “Scheduler” as a trigger point for Mule 4 or integration.

For example in some use cases where you need to do a specific tasks at particular period of time or repeatedly at fixed interval. Your integration flow can be scheduled via Scheduler.

Some of the examples in real time use case:

  • In case when you want to sync all Employees data extract from one system and load into another target system.
  • Case when you are design your integration in a batch mode and have requirement to read file from specific location FTP / File and in specific format and after read that file need to sync that data to end system.

Use cases are not just limited to above examples, but there are many more use cases in-line to same business logic.

General Settings to configure Scheduler.

  • Scheduling Strategy : Fixed Frequency   By Default this option will be selected.
    • It means you want to run your interface / integration /Mule flow at specific fixed frequency of time.
      • Example – Every 2 minutes, Every 10 Minutes, Every 1 hour etc.
    • Screenshot with an example of Every 2 Minutes.

Scheduler Mule4

 

 

 

 

 

 

Scheduler Component Properties Mule4

Cron is a widely used standard for describing time and date information. Read More.

If you have worked earlier in some of the integration tools or you worked in Java, Cron expressions were used in Quartz Scheduler. [ Quartz Job Scheduler is Open Source and freely available under the Apache 2 License ]. Read more about Quartz Scheduler in case you have time and interest.

Proof of Concepts for Cron Expression:

Step 1 – Create a Mule Project – Name as “SchedulerCronExpression”.

Step 2 – Use Scheduler Strategy as “Cron”

Scheduler_Cron_Expression

Step 3 – Configure properties

  • Expression – If you are a beginner, You can use only tools like http://www.cronmaker.com/ to generate basic expression for Scheduler.
    • Some sample Expressions are :
      • Every 1 Minute :
        • Cron Expression :     0 0/1 * 1/1 * ? *
      • Every 10 Minutes :
        • Cron Expression :     0 0/10 * 1/1 * ? *
      • Every 5 hours starting 12:00 hr
        • Cron Expression :     0 0 12 1/1 * ? *

Mule4_Scheduler_Cron_Strategy_Cron_Expression

  • Time Zone – It depends on java version on which you are running your Mule4 engine. Generally Java 8, it supports Java timezone values.

Some of list of valid values of Time Zones :

This content is for registered users only. Please login.

 

Mule4_Scheduler_Cron_TimeZone

Step 4 : Add logger statement to check the Scheduler is working fine.

“Lets Test Cron Expression-” ++ (now() as String {format: “dd MMM yyyy HH:mm:ss z”})

Step 5 : Deploy the Mule Project and run.

Overall Mule Flow will look like below :

Proof_Of_Concepts_Mule4


 

If you are interested in Learning Mulesoft and upskilling yourself on Mule4. Please contact us by filing the Enquiry Form.

We do provide instructor-led Mulesoft courses for Developers and Architects who want to get hands-on experience using the Anypoint Platform to build APIs and integrations.

Share

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.