Open sudhirbitsgoa opened 6 years ago
Hi,
var kue = require('kue-scheduler'); var Queue = kue.createQueue({ restore: true }); //create a job instance var job = Queue .createJob('every', {time:'every 10 secs'}) .attempts(3) // .backoff(backoff) .priority('normal') .save(function(err) { console.log('the err', err) console.log(job.id); }) //schedule it to run every 2 seconds Queue.every('10 seconds', job);
the above will act as publisher. Run this and this will create a recurring job with some id. And you can stop this process
var kue = require('kue-scheduler'); var Queue = kue.createQueue({ restore: true, worker: true }); Queue.process('every', function(job, done) { done(); console.log(job.data); }); let i=0 setInterval(() => { console.log(i++); }, 1000)
In other file copy this code and run this. As expected for every 10s a job is pushed to queue and finised.
But if we run above code in multiple terminals at same time, the jobs are pushed at random intervals not 10s. This is weird behaviour.
if i set to unique job then it works.
Hi,
the above will act as publisher. Run this and this will create a recurring job with some id. And you can stop this process
In other file copy this code and run this. As expected for every 10s a job is pushed to queue and finised.
But if we run above code in multiple terminals at same time, the jobs are pushed at random intervals not 10s. This is weird behaviour.