In BullMQ, a sophisticated Redis-based job queue for Node.js, events are emitted during the lifecycle of jobs. These events can be utilized to monitor job progress or trigger certain actions when something occurs.
Here are some common events:
completed: Emitted every time a job has been completed successfully.
failed: Emitted when a job fails to execute.
stalled: This is emitted when a job has been stalled. Note that job stalling is a sign of improper shutdown of your processing function.
progress: Emitted when a job updates its progress percentage.
waiting: Emitted when a job is waiting in the queue (i.e., it has been added).
active: Emitted when a job starts to be processed (i.e., moved from waiting state to active).
Here's an example of how you can listen to these events:
Remember, Jobs are atomic and every event is tied to each specific job instance. You should not use these events as a mechanism to issue commands to other processes or as inter-process communication.