I'm trying to use Kue to schedule jobs.
But I'm trying to find a way to check if a queue with some name already exists.
This is my code until now. The problem is that it keeps creating queues everytime I ran node.
How can I check if a Queue name 'email' already exists?
var queue = kue.createQueue();
var job = queue.create('email', {
title: 'Welcome to the site',
to: '[email protected]',
template: 'welcome-email'
}).save();
job.on('complete', function(result){
console.log('Job completed with data ', result);
});
kue.app.listen(3001);
queue.process('email', function(job, done){
email('[email protected]', done);
});
function email(address, done) {
console.log(address);
// email send stuff...
done();
}
From the documentation that I read, it points out that only one instance of queue is create per node process here https://github.com/Automattic/kue#processing-jobs
I've started working on Kue just couple of days back and as per my understanding, there's only one instance on which you register for events. Let's say you have jobs of types 'email', 'sms' and 'weeklynotifications'. You would register with queue for such events using
So, in short if you plan to use multiple queues for each kind of a task, this may not be possible. One queue for all kind of tasks.