我正在尝试在 Node.js 中使用公牛构建一个简单的排队系统。代码运行得很好。但是当我运行代码时,我不断收到“未定义”警告。我怎样才能停止警告,或者它是我的代码。提前致谢!
警告如下所示:
undefined
Hello there, I am Queue number: , 2121, Job Data: 1.
Hello there, I am Queue number: , 2122, Job Data: 2.
Hello there, I am Queue number: , 2123, Job Data: 3.
.....
.....
排队脚本:
// Import queuing module bull
const Queue = require('bull');
const queue = new Queue('count', {
limiter: {
max: 5000, // Limit the queue to a maximum of 5000 jobs per 10 seconds
duration: 10000
},
redis: {
host: "127.0.0.1",
port: "6379",
password: ""
}
});
// Add to waiting queue
function wait(msg){
for(let i=1;i<100;i++){
queue.add(i);
}
queue.process((job, jobDone) => {
console.log(`${msg}, ${job.id}, Job Data: ${job.data}.`);
jobDone();
});
}
// Run Queue
console.log(wait('Hello there, I am Queue number: '));