Multiple jobs for same processor not working

77 views Asked by At

If you try adding multiple jobs for the same processor, then the jobs are getting added but not processed. Most of the time only one of added jobs gets processed. I want all the added jobs to be processed, I even tried with delay, but still the problem persists.

const recipients = ['9988998899', '6677887766'];
for (const recipient of recipients) {
    data.recipient = recipient;
    const job = await this.bsQueue.add('send-push', data);
    this.logger.debug(`Job whatsapp push with id: ${job.id} added!`);
}
1

There are 1 answers

0
Deeksha Prabhakar On

Try adding a unique jobId

const recipients = ['9988998899', '6677887766'];
for (const recipient of recipients) {
    data.recipient = recipient;
    const job = await this.bsQueue.add(
        'send-push', 
         data, 
         {
             jobId: recipient
         }
    );
    this.logger.debug(`Job whatsapp push with id: ${job.id} added!`);
}

https://github.com/taskforcesh/bullmq/issues/488#issuecomment-825774630