Process only 1 job using queue.process
Created by: cbjuan
Hi
Rather than an issue, this is a question about Bull. I'm coding a queues system where I don't need to process the queue in a continuous way (like it does queue.process()
) but I need retrieve only one job each time I want (instead of processing every job available).
I tried to do this using process
by this way:
const consumeJob = function(queue) {
return new Promise(
function(resolve, reject){
queue.isReady().then(() =>{
queue.process(function(job){
queue.close();
resolve(job);
});
})
.catch(function(error){
reject(error);
});
}
);
};
In this case, using queue.close()
I destroy the Redis connection, so if I want to retrieve other job (or continue operating using Bull) without reinitiating the script (or Node server) I get the error Error: Connection is closed
. Knowing that, I would like to ask:
- If there is another way of obtaining only 1 (or N) job(s) using the
queue.process
method. - Is it possible to reconnect Redis after the
queue.close()
to continue using bull in other functions and parts of my code?
Thanks in advance