Guys, its possible do something like that?
I want to have many queues, if i have a sequence of messages to send. Those messages have to be sent in the right sequence to the same number, but the sequence is not important between numbers.
This way works, but a think, it probably leaves a lot of leaks on the memory. Because of queue.process(job.data.phone.toString(), 1, processMessage) who may not be used after the conversation ends, for example
message-sender
const arr = Array.from(new Array(5))
let phones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
phones.forEach(async phone => {
arr.forEach(async (_, key) => {
let message = `${key}\t`
queue.create('managequeue', { phone, message })
.removeOnComplete(true)
.save( function(err){
if( err ) console.log(err);
})
})
})
woker
const phones = []
queue.process('managequeue', 1, function(job, done){
queue.create(job.data.phone.toString(), { phone: job.data.phone, message: job.data.message })
.removeOnComplete(true)
.save()
if(!queues.includes(job.data.phone)) {
queue.process(job.data.phone.toString(), 1, processMessage)
phones.push(job.data.phone)
}
done()
})
Guys, its possible do something like that?
I want to have many queues, if i have a sequence of messages to send. Those messages have to be sent in the right sequence to the same number, but the sequence is not important between numbers.
This way works, but a think, it probably leaves a lot of leaks on the memory. Because of
queue.process(job.data.phone.toString(), 1, processMessage)who may not be used after the conversation ends, for examplemessage-sender
woker