1

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

Gopi
  • 105
  • 1
  • 7
  • 24
  • could you plz provide me the solution – Gopi Jan 10 '17 at 13:36
  • 00:00, 00:45, 1:30,2:15,3:00 and so on – Gopi Jan 10 '17 at 13:39
  • A comment asking for answers is not useful; you already asked for answers by posting the question. What do you mean by "after deployment immediately"? Do you want to start at some arbitrary time, or at midnight? – Keith Thompson Jan 10 '17 at 17:11
  • After deploying the application.Start polling once and then after 45 minutes of that time. – Gopi Jan 11 '17 at 06:51

7 Answers7

2

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>
...
Möoz
  • 847
  • 2
  • 14
  • 31
  • In future I need not run the poll on Sundays. In this case I could not achieve with fixed-frequency-scheduler. Is there any way of doing to restrict by using in fixed-frequency-scheduler. Could you plz provide if possible.. If not Could you plz provide solution with cron expression. – Gopi Jan 11 '17 at 05:13
  • You did not mention that it shouldn't run on Sundays. But that's ok, you can add a Groovy component to check if it's Sunday, and stop processing if it is. – Möoz Jan 11 '17 at 19:07
1

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 * * *

  • This is a regular cron (crontab), whereas Mule uses Quartz Cron scheduling. Quartz does allow 45 minute intervals. – Möoz Jan 11 '17 at 19:08
1

run every 10 seconds

0/10 * * * * ?

run every 45 minutes

* 0/45 * * * ?
Buddhi
  • 2,224
  • 5
  • 32
  • 43
0
  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).

Senthil c
  • 341
  • 2
  • 3
0

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

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.

dlb
  • 357
  • 3
  • 13
-1

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