---
schema_version: "1"
id: a5965851fed6f7b30a8381af2e38fcfe6f87551d8d5ed8da3da3bc24f5dbc869
title: Scheduler Endpoint (Trigger)
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.4/scheduler-concept.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.4/scheduler-concept
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a1e35d0655f5368a98550733be5e436487f591be0e91e23e95714562f5ae4be1
description: MuleSoft Documentation Site
release: "4.4"
latest: false
---
---
product: Mule Runtime
version: 4.4
---

# Scheduler Endpoint (Trigger)

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The Scheduler component is a Mule event source that triggers the execution of a flow based on a
time-based condition. For example, a Scheduler might create and send a message that will trigger the
flow processing every 5 seconds or every day at 12:00 in a given time zone.

Consider the following when adding a Scheduler to your Mule application:

- Schedulers use the same timezone as the machine on which Mule is running. However, if an
  application is running in CloudHub, the Scheduler conforms to the UTC timezone, regardless of the
  geographic region in which the application is running.

  To set a different time zone for the Scheduler, see `timeZone` in
  [Cron (`<cron/>`)](#props_cron_expressions).

- The `disallowConcurrentExecution` property enables you to prevent the Scheduler from triggering
  the execution of the flow while a previously-triggered execution is running.

- If [back-pressure](https://docs.mulesoft.com/mule-runtime/4.4/execution-engine#backpressure) occurs because no resources are available at the
  time of the scheduled trigger, Mule skips that execution.

- In a Mule runtime engine cluster or multi-worker CloudHub deployment, the Scheduler executes only
  on the primary node (that is, only in one Mule instance).

## Architecture

Like other Mule event source components, a Scheduler is the first component in a Mule flow.

![Scheduler component in Mule flow](/mulesoft/current/en-us/mule-runtime/4.4/_images/scheduler-component-ex.png)

The XML for the Scheduler consists of the following elements:

- `<scheduler />`: Top-level element of the Scheduler.

- `<scheduling-strategy />`: Second-level element that accepts one of the following children:

  - `<fixed-frequency />`: For common scheduling frequencies, such as every second.

  - `<cron />`: For [cron expressions](#cron_expressions) and time zone settings.

The Scheduler sets a scheduling strategy at a fixed frequency or an interval based on a cron
expression. For example:

- The fixed frequency setting in the following Scheduler executes every fifteen seconds:

  ```xml
  <flow name="ex-fixed-frequency-flow" >
    <scheduler doc:name="Scheduler">
      <scheduling-strategy>
        <fixed-frequency frequency="15" timeUnit="SECONDS" />
      </scheduling-strategy>
    </scheduler>
    <!-- One or more processors here. -->
  </flow>
  ```

- The cron expression in this Scheduler triggers the generation of a Mule message in a new execution
  of the flow every fifteen seconds:

  ```xml
  <flow name="ex-cron-expression-flow" >
    <scheduler doc:name="Scheduler" >
      <scheduling-strategy >
        <cron expression='0/15 * * * * ? '/>
      </scheduling-strategy>
    </scheduler>
    <!-- One or more processors here. -->
  </flow>
  ```

At least one processor must follow the Scheduler. Processors include Mule components and connector
operations, such as an HTTP Request operation or Transform Message component. Failure to provide a
processor produces a `MuleRuntimeException` and causes the deployment of the Mule application to
fail with the following ERROR message in the logs (edited for readability):

```logs
ERROR ...MuleRuntimeException ...
The content of element 'flow' is not complete.
One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor,
"http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor}'
is expected.
```

For Scheduler attributes, see [Reference](#reference).

## Reference

The Scheduler elements accept attributes for configuring the execution interval and concurrency.

### Scheduler (`<scheduler/>`)

By default, the Scheduler does not wait for one execution of a given flow to complete before
executing another instance of the flow at the configured cadence. You can change this behavior by
setting the `disallowConcurrentExecution="true"` attribute directly in the configuration XML.

<table><colgroup><col> <col></colgroup><thead><tr><th>Attribute XML</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>disallowConcurrentExecution</code></p></div></div></td><td><div><div><p>When this attribute is set to <code>true</code>, the Scheduler skips its scheduled execution if a previous execution is still running. Once the flow finishes, the Scheduler executes at the next configured interval. The default value is <code>false</code>.</p></div></div></td></tr></tbody></table>

In the following example, the Scheduler skips its execution if the flow takes longer to complete
than the fixed frequency of 10 milliseconds:

```xml
<flow name="scheduler-disallowConcurrentExecution-ex" >
  <scheduler doc:name="Scheduler" disallowConcurrentExecution="true" >
    <scheduling-strategy>
      <fixed-frequency frequency="10" timeUnit="MILLISECONDS"/>
    </scheduling-strategy>
  </scheduler>
  <!-- processors here -->
</flow>
```

Each time a Scheduler skips its execution, Mule logs an `Execution skipped` message, for example
(edited for readability):

```logs
INFO  2022-11-09 15:15:43,082 ...
...scheduler.DefaultSchedulerMessageSource:
Flow 'scheduler-disallowConcurrentExecution-ex' is already running and
'disallowConcurrentExecution' is set to 'true'. Execution skipped.

INFO  2022-11-09 15:15:43,083 ...
...scheduler.DefaultSchedulerMessageSource:
Flow 'scheduler-disallowConcurrentExecution-ex' is already running and
'disallowConcurrentExecution' is set to 'true'. Execution skipped.
```

### Fixed Frequency (`<fixed-frequency/>`)

The fixed frequency scheduling strategy accepts the following attributes:

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Attribute</th><th>XML</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><strong>Frequency</strong></p></div></div></td><td><div><div><p><code>frequency</code></p></div></div></td><td><div><div><p><code>1000</code></p></div></div></td><td><div><div><p>The frequency at which the Scheduler triggers the flow given the <code>timeUnit</code> setting.</p></div></div></td></tr><tr><td><div><div><p><strong>Start Delay</strong></p></div></div></td><td><div><div><p><code>startDelay</code></p></div></div></td><td><div><div><p><code>0</code></p></div></div></td><td><div><div><p>The amount of time to delay execution of the Scheduler for the first time after the application starts. This property uses the same <code>timeUnit</code> as the frequency.</p></div></div></td></tr><tr><td><div><div><p><strong>Time Unit</strong></p></div></div></td><td><div><div><p><code>timeUnit</code></p></div></div></td><td><div><div><p><code>MILLISECONDS</code></p></div></div></td><td><div><div><p>One of the following time units for the values of <code>frequency</code> and <code>startDelay</code>:</p></div><div><p><code>MILLISECONDS</code>, <code>SECONDS</code>, <code>MINUTES</code>, <code>HOURS</code>, or <code>DAYS</code></p></div></div></td></tr></tbody></table>

This strategy delays executes the Scheduler every 10 seconds after an initial 10 second delay:

```xml
<scheduler doc:name="Scheduler" >
  <scheduling-strategy >
    <fixed-frequency frequency="10" timeUnit="SECONDS" startDelay="10"/>
  </scheduling-strategy>
</scheduler>
```

### Cron (`<cron/>`)

For more complex scheduling strategies, you can use a cron expression.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute</th><th>XML</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><strong>Expression</strong></p></div></div></td><td><div><div><p><code>expression</code></p></div></div></td><td><div><div><p>A cron expression for triggering the Scheduler. There is no default cron expression. For guidance with expressions, see <a href="#cron_expressions">Cron Expressions</a>. Example: <code>expression="1 1 1 1,7 * ?"</code></p></div></div></td></tr><tr><td><div><div><p><strong>Time Zone</strong></p></div></div></td><td><div><div><p><code>timeZone</code></p></div></div></td><td><div><div><p>Time zone passed as a system property, or in a machine’s operating system. <a href="https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html" target="_blank" rel="noopener">Java time zone</a> values are supported. Avoid Java abbreviations, such as <code>PST</code> and <code>AGT</code>, and instead use the full-name Java equivalents, such as <code>America/Los_Angeles</code>. Example: <code>timeZone="America/Argentina/Buenos_Aires"</code></p></div></div></td></tr></tbody></table>

The following example uses a cron expression to trigger the flow at 12:00 every day in the
`America/Los_Angeles` time zone.

```xml
<flow name="componentsFlow">
  <scheduler>
    <scheduling-strategy>
      <cron expression="0 0 12 * * ?" timeZone="America/Los_Angeles"/>
    </scheduling-strategy>
  </scheduler>
  <logger message="my message"/>
</flow>
```

## Cron Expressions

Cron is a widely used standard for describing time and date information. The Cron Expression
(`<cron expression />` scheduling strategy (`<scheduling-strategy >`) is useful for triggering a
flow at intervals not available through the Fixed Frequency scheduling strategy.

The Scheduler keeps track of every second and creates a Mule event when the Quartz Cron expression
matches your time-date setting. You can trigger the event just once or at regular intervals.

A date-time expression consists of six required settings and can include the optional year setting.
Specify the settings in the following order:

1.  Seconds (`0`\-`59`)

2.  Minutes (`0`\-`59`)

3.  Hours (`0`\-`23`)

4.  Day of month (`1`\-`31`)

5.  Month (`1`\-`12` or `JAN`\-`DEC`)

6.  Day of the week (`1`\-`7` or `SUN`\-`SAT`)

7.  Year (empty or a 4-digit year between `1970`\-`2199`, for example, `2019`)

The Scheduler supports Quartz Cron expressions. Here are a few examples:

<table><colgroup><col> <col></colgroup><thead><tr><th>Expression</th><th>Behavior</th></tr></thead><tbody><tr><td><p><code>1/2 * * * * ?</code></p></td><td><p>Run every 2 seconds of the day, every day.</p></td></tr><tr><td><p><code>0 15 10 ? * *</code></p></td><td><p>Run at 10:15 a.m., every day. <code>0 15 10 * * ? *</code> and <code>0 15 10 * * ?</code> produce the same effect.</p></td></tr><tr><td><p><code>0 15 10 * * ? 2019</code></p></td><td><p>Run at 10:15 a.m., every day during the year 2019.</p></td></tr><tr><td><p><code>0 * 14 * * ?</code></p></td><td><p>Run every minute starting at 2pm and ending at 2:59pm, every day.</p></td></tr><tr><td><p><code>0 0/5 14 * * ?</code></p></td><td><p>Run every 5 minutes starting at 2pm and ending at 2:55pm, every day</p></td></tr><tr><td><p><code>1 1 1 1,7 * ?</code></p></td><td><p>Run the first second of the first minute of the first hour, on the first and seventh day, every month.</p></td></tr></tbody></table>

The Scheduler component also supports Quartz Scheduler special characters:

- `*`: All values.

- `?`: No specific value.

- `-`: Range of values, for example, `1-3`.

- `,`: Additional values, for example, `1,7`.

- `/`: Incremental values, for example, `1/7`.

- `L`: Last day of the week or month, or last specific day of the month (such as `7L` for the last
  Saturday of the month).

- `W`: Weekday, which is valid in the day-of-month field and must follow a specific day. For
  example, `15W` for the weekday nearest to the 15th of the month.

- `#`: "nth" day of the month. For example, `#3` is the third day of the month.

See [CronExpression](https://www.quartz-scheduler.org/api/2.3.0/org/quartz/CronExpression.html) for
more information.

This example logs the message "hello" every second:

```XML
<flow name="cronFlow" >
  <scheduler doc:name="Scheduler" >
    <scheduling-strategy >
      <cron expression="* * * * * ?" />
    </scheduling-strategy>
  </scheduler>
  <logger level="INFO" doc:name="Logger" message='"hello"'/>
</flow>
```

Note that there are a number of free online tools that can help you build Cron expressions.

## Examples in Anypoint Exchange

The following examples in [Anypoint Exchange](https://www.mulesoft.com/exchange/) show use cases for
a Scheduler component:

- _Data Sync Using Watermarking and Batch_

- _Import Contacts into Microsoft Dynamics CRM_

- _Import Leads into Salesforce_

- _Importing a CSV File into mongoDB_

- _Importing an Email Attachment Using the IMAP Connector_

- _Salesforce to MySQL Database Using Batch Processing_

- _Sending a CSV File Through Email Using SMTP_

To download and open the project from Anypoint Studio, see
[Import a Mule Project from Exchange](https://docs.mulesoft.com/studio/import-project-exchange).

## Debugging in Anypoint Studio

In Anypoint Studio [debug mode](https://docs.mulesoft.com/studio/visual-debugger-concept), the Mule application disables
the triggering of events. You can manually execute the Scheduler component when debugging by
clicking the green arrow icon in Studio that appears at the bottom of the component, for example:

![Debug arrow in the Scheduler](/mulesoft/current/en-us/mule-runtime/4.4/_images/scheduler-component-debug-ex.png)

## See Also

- [Flow and Subflow Scopes](https://docs.mulesoft.com/mule-runtime/4.4/flow-component)
