I'm using agenda jobs in nodejs. I was wondering if it's possible to define a job with a dependency. In my case I have 3 jobs, each one of the jobs execute a part of a whole logic, which is quite big, that's why they are separated.
- In the
Job 1
, I collect info from the database, transform them and perform a few tasks. - In the
Job 2
, I get all the data that had been previously processed by theJob 1
and perform new transformations.. - In the
Job 3
, I get again all the data that had been processed in theJob 2
and send a few reports.
I have those tasks schedule to be executed every 5 minutes. But the thing is that the 3 of them are schedule at the same time because, they are schedule dynamically.
job1.schedule("now");
job1.repeatEvery('5 minutes');
job2.schedule("now");
job2.repeatEvery('5 minutes');
job3.schedule("now");
job3.repeatEvery('5 minutes');
As it's configured currently, to process one instance that needs to go through the 3 jobs, worst case scenario the user will need to wait 15min, which is not ideal.
I was wondering if there is an option to define that the tasks should be executed as soon as the previous task is finished. I'm aware that a possible workaround will be to schedule the jobs with a few minutes of difference, but given that depending on the number of instances the job can require more or less time this doesn't work for me.