In one of the projects that I’ve assigned to has given me the trouble of synchronization of batches to carry all data from one location to another remote location. The story is that we have a few of batches some of them scheduled to be launched every two minutes or 2 hours, but we’ve come to realize that they all work endlessly.
I did dig information on internet and finally have come up with a permanent solution on creating Spring cron job expressions.
Normally a simple Spring cron job expression consists of 6 digits of slots and each slots corresponds to a time frame.
* * * * * *
Second Minute Hour Day of the month Month Days of a week
In this given structure you do define the job at a specific time that it’s being fired.
What I entered before
<task:scheduled-tasks scheduler="orderScheduler"> <task:scheduled ref="orderBatchRunScheduler" method="run" cron="* */3 * * * *" /> </task:scheduled-tasks>
How I altered
<task:scheduled-tasks scheduler="orderScheduler"> <task:scheduled ref="orderBatchRunScheduler" method="run" cron="0 */3 * * * *" /> </task:scheduled-tasks>
So * all caused the tasks to run endlessly, to observe the indication of symbols
* : matches any
/ : every
? : for no specific values
using 0 instead of * has enabled batch to run only at its given specific time, not run every single second. because * meets the criteria of any so that i was being fired up every single time.