Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
How to push Queue object to array | bull framework | node js

In the following code sample I am trying to push sampleQueue1, sampleQueue2, sampleQueue3 but I am getting error,

const Queue = require('bull');
const sampleQueue1 = new Queue('sample1', 'redis://127.0.0.1:6379');
const sampleQueue2 = new Queue('sample2', 'redis://127.0.0.1:6379');
const sampleQueue3 = new Queue('sample3', 'redis://127.0.0.1:6379');
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));

const queueProcess = async(job, done) => {
    console.log(job.data);
        await delay(5 * 1000);
        job.log("Testing Log");
        if(job.data % 2 == 0)
                done(null, "even number");
        else
                done(new Error('error transcoding'));
}
sampleQueue1.process(queueProcess);
sampleQueue2.process(queueProcess);
sampleQueue3.process(queueProcess);
let queues = [sampleQueue1, sampleQueue2, sampleQueue3]
(async() => {
    await sampleQueue.obliterate({ force: true });
    array = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
    array.forEach(val => {
        console.log(val);
        let rand = Math.floor(Math.random() * queues.length);
        queues[rand].add(val);
    });
})();
console.log("Job done");

When I run the above code, I am getting the following error,

/test.js:16
(async() => {
^

TypeError: [sampleQueue] is not a function

Help me to fix this issue.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!