bull不带redis的队列管理

ajsxfq5m  于 2021-06-10  发布在  Redis
关注(0)|答案(1)|浏览(547)

不使用redis就可以使用bull(作业管理)吗?
mu代码:

  1. @Injectable()
  2. export class MailService {
  3. private queue: Bull.Queue;
  4. private readonly queueName = 'mail';
  5. constructor() {
  6. this.queue = new Bull(this.queueName)
  7. }
  8. addTaskToQueue() {
  9. this.queue.process('send_mail',
  10. async (job: Bull.Job, done: Bull.DoneCallback) => {
  11. console.log('Send mail!');
  12. console.log(JSON.stringify(job.data));
  13. done();
  14. })
  15. }
  16. async send(year: number, month: number) {
  17. try{
  18. await this.queue.add('send_mail', {
  19. year,
  20. month
  21. });
  22. console.log('done');
  23. } catch(err){
  24. console.log(err);
  25. }
  26. }
  27. }

在运行我的控制台后,请告诉我此错误:

  1. { Error: connect ECONNREFUSED 127.0.0.1:6379
  2. at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
  3. errno: 'ECONNREFUSED',
  4. code: 'ECONNREFUSED',
  5. syscall: 'connect',
  6. address: '127.0.0.1',
  7. port: 6379 }

//////////////////////////////////////////////////////////////////////////////////////////

1cklez4t

1cklez4t1#

bull构建在redis之上,这是它的后端。没有redis你就无法使用它。您可以实现某种定制系统,不需要使用rxjs和一些状态管理的redis,但是bull必须有redis。

相关问题