Closed petr24 closed 7 years ago
Hi, yes, this is expected behavior because of how short your retry interval is (2 sec).
The server-side of job collection promotes waiting jobs to 'ready'
status on a "heartbeat" that defaults to 15 seconds. If you need less latency in the job promotion heartbeat, you can override the default using jc.promote([ms])
on the server:
https://github.com/vsivsi/meteor-job-collection#jcpromotemilliseconds---server-only
Hope that helps.
Ah okay, that works now. Thank you.
But I guess I still kind confused as to why I need the promote polling, If I am doing a reactive trigger, which triggers the job queue when a doc is added not every 15 seconds, and once it's kicked off the retry wait time takes it from there.
And what's the difference in use case between setting a time with jc.promote or pollInterval, are they the same or are they for different cases? That part kind confuses me.
Thanks.
These are two totally different things.
jc.promote()
Controls the server-side promotion of jobs from 'waiting'
to 'ready'
. This cannot be observed because it is not the database that is changing, time is what is changing. So the server must periodically poll the database querying for jobs with job.after <= currentTime
and that have no remaining dependencies.
The pollInterval
option on jc.processJobs()
and/or the .observe()
function that invokes queue.trigger()
are controlling how/when a worker is asking for new jobs when the local queue is not full. Your observe query is watching for jobs that are status: 'ready'
, and the way those jobs become ready is by being promoted on the server-side via the polled query I described above.
Hope that makes it more clear.
BTW, there is a long history of issues where this is discussed in more detail:
https://github.com/vsivsi/meteor-job-collection/search?utf8=%E2%9C%93&q=jc.promote%28&type=Issues
Ok that makes sense. Thanks for clearing it up. Thanks for that link. Some of those posts I skimmed through to find the "wait" time interval question I had. but I will read them more in depth.
I'll close this out.
Hey @vsivsi
Amazing package. I started writing my own queuing code, then found this. So thank you for saving me a lot of future time.
I am just getting started with the package, and for whatever reason, my wait time doesn't seem accurate.
Here is my job creation.
Here is the processJobs code
And a reactive observer to do triggers
And a log with timestamps of the retries. Consistently 15 seconds in between each go.
And the actual mongo doc that's in the collection
Am I screwing something up, or could this be a bug?
Thanks!