Contact Free trial Login

@Schedule Annotation

Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version.

The @Schedule annotation is a method level annotation that is used to schedule how often the method is called. To call a method every second you could use the following -

public class PingMe
    @Schedule(interval = 1000)
    public String ping()
        return "ping!";

The interval is defined in milliseconds. When the PingMe class is loaded in the Mule container a schedule will be set up to call the ping() method every second.

The @Schedule annotation also supports Introduction to Cron expressions expressions. These provide a powerful way to express time triggers.

The getStatus method below will be called every hour.

@Schedule(cron = "* * 0 * * ?") //every hour
public String getStatus()
    //use Twitter iBean


Argument Description Required


A cron command that specifies when to call the method.

You must set either cron or interval.


The number of milliseconds between two scheduled invocations of the method.

You must set either cron or interval


A reference to the org.mule.transport.quartz.config.ScheduleConfigBuilder object that is used to configure this scheduler job. This attribute can be used to reference a local schedule configuration builder using the name of the builder. Local configBuilder references can use the id value passed into the ScheduleConfigBuilder



The number of milliseconds that will elapse before the first event is fired. The default is -1, which means the first event is fired as soon as the application is started.


Introduction to Cron expressions

Cron is a UNIX tool that has been around for ever and is used for scheduling operating system tasks. It uses "cron expressions", which are able to create firing schedules such as: "At 8:00am every Weekday" or "every 5 minutes". Cron expressions are powerful but can be a little confusing so I have provided some examples below. A cron expression consists of 7 fields, one of which is optional, listed below.

Field Name Mandatory Allowed Values Allowed Special Chars




, - * /




, - * /




, - * /

Day of Month



, - * ? / L W C



1-12 or JAN-DEC

, - * /

Day of Week


1-7 or SUN-SAT

, - * ? / L C #



empty, 1970-2099

, - * /

Some examples

  • 0 0 12 * * ? Fire at 12pm (noon) every day

  • 0 15 10 ? * * Fire at 10:15am every day

  • 0 15 10 * * ? 2009 Fire at 10:15am every day during the year 2009

  • 0 * 14 * * ? Fire every minute starting at 2pm and ending at 2:59pm, every day

  • 0 0/5 14 * * ? Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day

  • 0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month

  • 0 11 11 11 11 ? Fire every November 11th at 11:11am

The Quartz documentation also provides an in depth description of what you can do with cron expressions.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub