bull通过eclient订阅队列的channel事件消息,然后在当前队列上发出本地或者全局的对应事件
local事件格式为 completed / failed ,代表事件所属job属于本地的queue
global事件格式为 global:completed / global:failed , 代表全局事件,无论 job 是否在本地queue运行
继承
就像多多数nodejs库一样,bull的Queue类继承了EventEmitter
util.inherits(Queue, EventEmitter);
可以直接使用 queue 对象来监听各种事件
on(event: string, callback: (...args: any[]) => void): this;
on(event: 'error', callback: ErrorEventCallback): this;
on(event: 'waiting', callback: WaitingEventCallback): this;
on(event: 'active', callback: ActiveEventCallback<T>): this;
on(event: 'stalled', callback: StalledEventCall