OptimalBits / bull

Premium Queue package for handling distributed jobs and messages in NodeJS.
Other
15.47k stars 1.43k forks source link

Job events #1039

Open samuelgoldenbaum opened 6 years ago

samuelgoldenbaum commented 6 years ago

Apologies if covered, but I don't see job events fired on completion - only the queue fires events for job completion. Is this correct for Bull?

manast commented 6 years ago

All the events emitted by the queues can be found here: https://github.com/OptimalBits/bull/blob/master/REFERENCE.md#events

samuelgoldenbaum commented 6 years ago

Thanks @manast, these seem to only exist on the queue itself, not the job. While I appreciate the subscriber is traditionaly separate from the process adding the job, I have a scenario where jobs are very short lived and need to have events fire on the job i.e let job = queue.add(params); job.on('complete', result => { ... });

manast commented 6 years ago

There would be no performance penalty in just doing this:

queue.on('completed', (job, result) => {
 // job.id can be used to map it to an exact added job
}

or if the jobs are processed in separated workers you will need to do this:

queue.on('global:completed', (jobId, result) => {
 ...
}
entrptaher commented 6 years ago

Not totally related, but if there was an job event for 'updated', we could use this for talking to the job.

samuelgoldenbaum commented 5 years ago

Any progress on this?

Ideally looking for a set of events similar to the main Queue so we can have:

let queue = new Queue('player-queue');
...
let job = queue.add({name: 'dude'});
job.on('complete', result => { ... });
apapacy commented 3 years ago

I need in one thread, for example in a controller, to send a task to a handler and in the same controller to wait for the request execution result. A more detailed rationale can be read here.

https://github.com/bee-queue/bee-queue/wiki/Origin