【发布时间】:2020-07-14 17:57:20
【问题描述】:
不使用 Redis 是否可以使用 Bull(用于作业管理)?
亩代码:
@Injectable()
export class MailService {
private queue: Bull.Queue;
private readonly queueName = 'mail';
constructor() {
this.queue = new Bull(this.queueName)
}
addTaskToQueue() {
this.queue.process('send_mail',
async (job: Bull.Job, done: Bull.DoneCallback) => {
console.log('Send mail!');
console.log(JSON.stringify(job.data));
done();
})
}
async send(year: number, month: number) {
try{
await this.queue.add('send_mail', {
year,
month
});
console.log('done');
} catch(err){
console.log(err);
}
}
}
在运行我的控制台后出现这个错误:
{ Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 6379 }
/////////////////////////////////////// ///////////////////////////////////
【问题讨论】:
标签: javascript typescript redis nestjs