Sandesh Bhoir
Sandesh Bhoir

Reputation: 51

Multiple jobs for same processor not working

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!`);
}

Upvotes: 0

Views: 108

Answers (1)

Deeksha Prabhakar
Deeksha Prabhakar

Reputation: 25

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

Upvotes: 0

Related Questions