mywei1989 / egg-bus

🐣 用 egg 编写优雅的队列与事件
MIT License
51 stars 8 forks source link

app.bus.get 无法获取queue队列 #15

Closed nanhupatar closed 2 years ago

nanhupatar commented 3 years ago

job文件

class BaseQueue extends Job {
  static get queue() {
    return 'accessTokenSchedule'; // 使用的队列名称
  }

  async run(info) {
    try {
      const queue = await this.app.bus.get('accessTokenSchedule');
      console.log('queue->>', queue);
    } catch (error) {
      console.log(error);
    }
  }
}

触发

      app.bus.dispatch(
        'accessTokenSchedule',
        {}
        // {
        //   repeat: {
        //     every: 10000,
        //     limit: 10,
        //   },
        // }
      );

queue为undefined

nanhupatar commented 3 years ago

破案了 需要这样使用 this.app.bus.get('bus:accessTokenSchedule') 一个隐形的小问题

seekcx commented 3 years ago

这是一个 bug。如果直接改,可能是个 break change。暂时也没有发布大版本的计划,先这样吧。