You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following scenario: my queue contains three scheduled items (i.e. A, B, C). The external process that handles these items cannot be launched multiple times at the same time. For this reason, I would need Agenda to process A, wait until it's completed (or failed), then process B, wait, then finally C.
If I understand the documentation correctly, I would have to invoke Agenda like so using your example in the documentation:
Not calling done would still allow multiple jobs to be run at once, specifically on per-job concurrency, or entire queue concurrency. A job will be considered "finished" when you call done(). If you do not take done as an argument, then it will be marked as done when the function reaches the end. You shouldn't take done as an argument if you aren't going to call it, as then agenda will
If you want agenda to only ever run one job at a time, you can do the following:
agenda.maxConcurrency(1);
This tells agenda to only ever allow one job to be processing at once.
If you want to specify it for a specific job, you can do:
agenda.maxConcurrency(3);varstart=newDate();agenda.define('longer job',{},function(job,done){setTimeout(function(){varnow=newDate();console.log("Hello one - %d ms later",now-start);done();},1700);});agenda.define('long job',{concurrency: 1},function(job,done){setTimeout(function(){varnow=newDate();console.log("Hello two - %d ms later",now-start);done();},1000);});agenda.now('longer job');agenda.now('longer job');agenda.now('long job');agenda.now('long job');agenda.now('longer job');agenda.start();
Results in the following:
Hello two - 1026 ms later
Hello one - 1724 ms later
Hello one - 1725 ms later
Hello two - 2028 ms later
Hello one - 3425 ms later
done is a function which lets the agenda know that the job finished, and tells it to queue up the next job, given the current state of running jobs and concurrency limitations.
Hello,
I have the following scenario: my queue contains three scheduled items (i.e. A, B, C). The external process that handles these items cannot be launched multiple times at the same time. For this reason, I would need Agenda to process A, wait until it's completed (or failed), then process B, wait, then finally C.
If I understand the documentation correctly, I would have to invoke Agenda like so using your example in the documentation:
I should remove
done()
because I want Agenda to process the scheduled items synchronously, correct?Also, what is the content type and value of
job
anddone
? What should I be expecting back?Thanks!
The text was updated successfully, but these errors were encountered: