Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Poll Scheduler

By default, Poll Scopes in Mule are set to poll a resource every 1000 milliseconds for new data. At times, you may wish to adjust the default polling interval, or configure the polling schedule to follow a more complex logic. 

This document offers details on how to configure a polling schedule via two methods made available in Anypoint Studio:

Assumptions

This document assumes that your are familiar with Anypoint Studio and polling in general.  Read more about poll scopes in Mule.

Fixed Frequency Scheduler

As the name implies, this method of configuring a poll schedule simply defines a fixed, time-based frequency for polling a source. 

In Studio’s visual editor, open the Poll message processor’s properties editor. Select Fixed frequency scheduler, then adjust the values of the fields according to the table below.

poll_scheduler

Field Default Value Description XML

Frequency

1000

Polling frequency, relative to time unit.

frequency="1000"

Start Delay

0

Upon triggering the flow for the first time, Mule stalls the running of the poll for a specific amount of time. This time period is expressed in the same time units as the frequency.

startDelay="0"

Time unit

MILLISECONDS

The time unit for the frequency value.

MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS

-------
timeUnit="MILLISECONDS"
 
           

In Studio’s XML editor, add a fixed-frequency-scheduler child element to your poll element. Configure the child element’s attributes according to the table below.


    
            
         
1
2
3
4
<poll doc:name="Poll">
        <fixed-frequency-scheduler frequency="1000" timeUnit="MILLISECONDS" startDelay="0"/>
        <sfdc:authorize config-ref="SalesforceGlobal" display="Salesforce1" doc:name="Salesforce1"/>
    </poll>
Attribute Description Example

frequency

Polling frequency, relative to time unit. When set to 0 or a negative value, it switches to the default.

frequency="1000"

timeUnit

The time unit for the frequency value.

MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS

timeUnit="MILLISECONDS"

startDelay

Upon triggering the flow for the first time, Mule stalls the running of the poll for a specific amount of time. This time period is expressed in the same time units as the frequency.

startDelay="0"

Cron Scheduler

As the name implies, this method allows you to configure a polling schedule using cron expressions. If you’re not familiar with cron syntax, don’t be intimidated! It’s reasonably easy to learn, and you can even leverage online tools that can help you build cron expressions.

In Studio’s visual editor, open the Poll message processor’s properties editor. Select Cron scheduler, then adjust the value of the Expression field according to the table below.

cron_scheduler

Field Default Value Description XML

Expression

  -

Use cron expression to define poll schedule.

expression="1 1 1 1,7 *"

The table below offers a few examples of typical Cron expressions:

Expression Behavior

0 0 12 * * ?

Poll at 12pm (noon) every day

0 15 10 ? * *

Poll at 10:15am every day

0 15 10 * * ?

Poll at 10:15am every day

0 15 10 * * ? *

Poll at 10:15am every day

0 15 10 * * ? 2005

Poll at 10:15am every day during the year 2005

0 * 14 * * ?

Poll every minute starting at 2pm and ending at 2:59pm, every day

0 0/5 14 * * ?

Poll every 5 minutes starting at 2pm and ending at 2:55pm, every day

1 1 1 1,7 *

Poll the first day of January and the first day of June, every year (in the first second of the first minute of the first hour)

In Studio’s XML editor, add a schedulers:cron-scheduler child element to your poll element. Configure the child element’s attribute according to the table below.


    
            
         
1
2
3
4
<poll doc:name="Poll" frequency="1000">
        <schedulers:cron-scheduler expression="1 1 1 1,7 *"/>
        <sfdc:authorize config-ref="SalesforceGlobal" display="Salesforce1" doc:name="Salesforce1"/>
    </poll>
Parameter Default Value Description Example

expression

-

Use cron expression to define poll schedule.

expression="1 1 1 1,7 *"

Here are a few examples of typical Cron expressions:

Expression Behavior

0 0 12 * * ?

Poll at 12pm (noon) every day

0 15 10 ? * *

Poll at 10:15am every day

0 15 10 * * ?

Poll at 10:15am every day

0 15 10 * * ? *

Poll at 10:15am every day

0 15 10 * * ? 2005

Poll at 10:15am every day during the year 2005

0 * 14 * * ?

Poll every minute starting at 2pm and ending at 2:59pm, every day

0 0/5 14 * * ?

Poll every 5 minutes starting at 2pm and ending at 2:55pm, every day

1 1 1 1,7 *

Poll the first day of January and the first day of June, every year (in the first second of the first minute of the first hour)

See Also