How to make a Job execute after another Job finishes? #113
-
|
I have an application that is needing some complex orchestration and i'm evaluating Sidequest. This app scrapes medical records from a health provider website It access insurer website to retrieve information about the medical records Than, saves back the information to provider website It started with only one insurer, now it has four insurers and the architecture is showing its limit since is doing the work, one insurer after the other. I need to change to the following architecture:
The jobs in step 2 must be executed after job 1 finished Is there a way to accomplish that with Sidequest? As far as i know queue priority will not work because, even if i set job 3 to a queue with lower priority, as soon as a worker is available it will start the job |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
|
Having a way to know when a job is finished is enough to my use case. I can queue the read records job, on finished queue the read insurer jobs. When all finished i queue the save record job |
Beta Was this translation helpful? Give feedback.
-
|
Hey @blikblum. It's somewhat possible. You can enqueue jobs from within other jobs, so what you can do is: Start your job number 1 You can, however, fetch the list of all jobs of a given type using What I suggest: Create a new job called Inside this job, you check if all the jobs from the ID array are completed using Inside it, you can even do some other shenanigans to check if one of the parallel jobs has permanently failed and skip it in that case, or notify you by email or other ways about failures. This is not ideal and a workflow would be better, but workflows are something we will implement only on Sidequest pro :) |
Beta Was this translation helpful? Give feedback.
-
|
I was thinking in using node-cron to poll the jobs status more or less what your suggested approach does. At first look, an advantage of using node-cron is not running an extra worker thread |
Beta Was this translation helpful? Give feedback.
-
|
I see. Well, the advantage of using Sidequest for this additional polling job would be easy tracking of status and all. Bear in mind that it will get into the job pool and Sidequest will respect your concurrency settings. |
Beta Was this translation helpful? Give feedback.
Hey @blikblum.
It's somewhat possible.
You can enqueue jobs from within other jobs, so what you can do is:
Start your job number 1
Then within job number 1, when it succeeds and before returning, call
Sidequest.enqueue()to enqueue your multiple jobs from step number 2.Here it's a bit trickier, because there is no easy way to know from within the parallel jobs if they all have completed.
You can, however, fetch the list of all jobs of a given type using
Sidequest.job.listor fetch a specific one usingSidequest.job.get.What I suggest:
Create a new job called
ProviderJobCheckerthat receives an array of job IDs containing all of the parallel jobs IDs. This should be enqueued right after …