bull icon indicating copy to clipboard operation
bull copied to clipboard

Job events

Open samuelgoldenbaum opened this issue 6 years ago • 6 comments

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?

samuelgoldenbaum avatar Aug 29 '18 18:08 samuelgoldenbaum

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

manast avatar Aug 29 '18 19:08 manast

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 => { ... });

samuelgoldenbaum avatar Aug 29 '18 19:08 samuelgoldenbaum

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) => {
 ...
}

manast avatar Aug 29 '18 20:08 manast

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

entrptaher avatar Oct 06 '18 14:10 entrptaher

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 => { ... });

samuelgoldenbaum avatar Feb 23 '19 14:02 samuelgoldenbaum

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

apapacy avatar Sep 25 '21 12:09 apapacy