Poll for every 45 minutes using cron

2.3k views Asked by At

I need to poll after deployment immediately i.e 0 seconds and then for every 45 mins using cron

Should poll as follows:: 00:00, 00:45, 1:30,2:15,3:00 and so on

7

There are 7 answers

1
Christian Pekeler On

I don't know how to poll in Mule, but I can help you with your cron schedule.

Cron doesn't support every-45-minutes. You'll have to break it into three cronjobs:

0,45 0-23/3 * * *

30 1-23/3 * * *

15 2-23/3 * * *

0
Senthil c On
  1. CRON expression to poll every 45 minutes, this will solve ur first problem.

    0 0/45 * 1/1 * ? *

  2. Running once immediately after the deployment can't be handled with "Poll" as far as I know. As a workaround, in addition to the Poll component above, create another flow with "QUARTZ Inbound Endpoint" and it has a repeatCount attribute which you can set it to "Zero"(this will run exactly once and won't repeat itself).

2
Möoz On

Why do you have to use cron?

Your best bet in this case is to not use cron, rather use Mule's in-built fixed-frequency scheduler:

Screen capture showing the in-built polling strategy within Mule

Note how the the default delay is "0" which means that it will run immediately upon deployment, then will run every 45 minutes after.

Here is the configuration-xml:

...
<flow name="polling-frequency-example-flow"
    processingStrategy="synchronous">
    <poll doc:name="poll-every-forty-five-mins">
        <fixed-frequency-scheduler frequency="45" timeUnit="MINUTES"/>
    </poll>
    <!-- Do Something -->
</flow>
...
0
Harish Kumar On

Cron expression (for every 45 mins): 0 0/45 * 1/1 * ? *

If you want to run every 45 mins(00:15,01:00 like this) use quartz. if you used poll operation it will not run every 45 mins, it will run every 45 mins when the project or flow deployed.

0
dlb On

Simply use the fixed frequency scheduler construct as stated by @Mooz and then get the current time, check if it is a Sunday and do not process if it is. A cron expression is not really directly intended to handle all of the constraints of running immediately, a frequency relative to starting time rather than a clock schedule, and a day scheduling even with Mule's extensions to cron. Other solutions would be to use two controllers, but this would seem cleaner to me.

0
satya sandeep On

Instead of using the Cron jobs just go with fixed frequency scheduler simply. set the value as follows:

frequency: 45 start delay as :0

Time unit as:minutes

0
Buddhi On

run every 10 seconds

0/10 * * * * ?

run every 45 minutes

* 0/45 * * * ?