Reputation: 275
I need to implement one functionality to start and stop worker queue using bullmq.
The complete scenario is when someone presses the start button on the front-end side. the job will be added to the worker and the queue will start and processing it. in the middle of the worker implementation if one will press the stop button. it needs to get a stop or can say pause the queue job. and then if one will start the job again. it should start again with the same queue job.
I would really appreciate any help, thanks in advance.
Upvotes: 3
Views: 1989
Reputation: 11
You can use.
await worker.pause()
The call above will wait for all the jobs currently being processed by this worker to complete (or fail). If you do not want to wait for current jobs to complete before the call completes you can pass true to pause the worker ignoring any running jobs:
await worker.pause(true);
See the doc: https://docs.bullmq.io/guide/workers/pausing-queues
Upvotes: 0