Hi,
I would like to see following scenario:
Is this possible?
Thanks
Listen to the event like this:
queue.on('event', listener, true);
sadly, that doesn't seem to work. Any option I need to set maybe?
write a test case so that we can reproduce it.
This it the code of Machine1:
var queue = require('bull');
var testQueue = queue('test',6379,'some.remote.redis', {password:'password'});
testQueue.on('completed', function(job, result){
console.log('JOB ' + job.jobId + ' completed with result: ' + JSON.stringify(result) );
createJob();
}, true);
testQueue.on('active', function(job, jobPromise){
console.log('JOB ' + job.jobId + ' started' );
}, true)
function createJob(){
testQueue.add({count: count})
.then(function(job){
console.log('JOB ' + job.jobId + ' created' );
});
}
createJob();
The code of Machine2:
var queue = require('bull');
var testQueue = queue('test',6379,'some.remote.redis', {password:'password'});
testQueue.process(1, function(job,done){
done(null, {hello:'world'});
console.log('JOB ' + job.jobId + ' completed' );
});
The events 'active' and 'completed' never get emitted on Machine1.
I noticed that:
`Events are by default local, i.e., they only fire on the listeners that are registered on the given worker, if you need to listen to events globally, just set to true the last argument:
queue.on('completed', listener, true):`
has been removed from the docs in the https://github.com/manast/bull docs. Has the functionality been removed at any time?
Does redis need any special setup to work in this scenario?
I tested both npm modules redis and ioredis, both work with pub/sub on my redis instance. I have no idea whats going wrong, please help.
Thank you!
Same workflow. same problem.
Nodejs last LTS 6.x
bull 2.0
redis 2.8.17
I'm also seeing the same behaviour.
Node 6.2
Bull 2.1.0
I did some digging and have found the issue:
foo would be emitted as progress@foo around the distributed system.listenDistEvent never actually listens to a distributed/global event since it never passes true as a third parameter to this.onYou can work around this until its fixed by (as a consumer) changing the queue subscription from queue.on('process', ..., true) to queue.on('process@<queuename>', ..., true) (replacing
@manast it seems there are some inconsistencies in how people should listen for global events. The docs tell people to add true to queue.on if you want to listen for a global event, however it does not mention anything about the global events having the queue name suffixed to them. The code, however, makes it seem like as a consumer you never need to pass the third parameter to queue.on, since it automatically subscribes and re-emits global events for you. What should be the correct behaviour here?
@manast any thoughts on this?
This issue is next in my todo list.
The proposal I have is that we remove the last parameter "isGlobal", and instead global events will be prefixed with 'global:'. So if you listen to 'global:completed' you listen to all completed events in that queue, but if you only listen to 'completed' you will only receive the events for that worker. What do you think?
Would a node that created an event emit both a non global and a global
event?
On 12 Mar 2017 20:39, "Manuel Astudillo" notifications@github.com wrote:
The proposal I have is that we remove the last parameter "isGlobal", and
instead global events will be prefixed with 'global:'. So if you listen to
'global:completed' you listen to all completed events in that queue, but if
you only listen to 'completed' you will only receive the events for that
worker. What do you think?—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/OptimalBits/bull/issues/394#issuecomment-285974678,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAl7C3YrQnHyNvV875R2P4ZtxiNaz9XQks5rlFgLgaJpZM4K87rH
.
Yes, the workers will always emit global events. This could be configured in the future to save resources if not needed.
Most helpful comment
This issue is next in my todo list.