I want to emit user defined events on Bull queue event emitter to be intercepted across Queues (and processors), but events appear not to work across processes.
I am using the Bull nestjs wrapper library but I think this is a Bull Queue issue not specific to nestjs wrappers.
Setup:
In my QueueA processor I am emitting two events on the QueueA event queue, one is intercepted in the same queue (processor) and one in another processor. A reference to the emitting queue is available to the receiving Queue to be able to call its .on function.
QueueA emits two events.
const x = this.QueueA.emit('event:test-event', {
message: 'internal',
});
const y = this.QueueA.emit('global:test-event', {
message: 'global',
});
I have injected a reference to QueueA into QueueB and register the QueueA event in the QueueB constructor:
batchQueue.on('event:test-event', (message) => {
trace('internal test event received', message);
});
In QueueB processor I have injected a reference to QueueA and registered the following in the constructor
queueA.on('global:test-event', (message) => {
console.log('external test event received', message);
});
The result is that the test-event fires in the QueueA event callback but the the global:test-event doesn't fire in QueueB.
Bulls assertion that prefixing 'global:' to events makes them visible between queues does not appear to work.