【问题标题】:Bull without Redis to queue managementBull 没有 Redis 来进行队列管理
【发布时间】: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


    【解决方案1】:

    Bull 构建在 Redis 之上,这是它的后端。没有 Redis 就无法使用它。您可能可以实现某种自定义系统,不需要像使用 RxJS 和一些状态管理的 Redis 之类的东西,但 Bull 必须有 Redis。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-05
      • 2021-07-08
      • 2021-08-04
      • 2022-11-22
      • 2021-09-13
      • 1970-01-01
      相关资源
      最近更新 更多