bull icon indicating copy to clipboard operation
bull copied to clipboard

Give ability to disable job processing in `BullModule.forRoot` method

Open leonardbinet opened this issue 1 year ago • 5 comments

Is there an existing issue that is already proposing this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe it

In our architecture, we have two types of "applications", that share the same code:

  • web servers: serve clients requests
  • workers: process bullmq jobs

We would like to be able disable job processing on some instances only.

Describe the solution you'd like

In BullModule.forRoot method, have a disabled prop, to disable the processing of jobs on this instance.

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

Be able to easily disable processing.

leonardbinet avatar Feb 26 '24 13:02 leonardbinet

What about not importing BullModule.forRoot in the context of a web server application?

kamilmysliwiec avatar Feb 27 '24 07:02 kamilmysliwiec

@kamilmysliwiec will the web server still be able to produce messages if BullModule is not initialised at all?

jarPotato avatar May 11 '24 13:05 jarPotato

@kamilmysliwiec sorry I didn't notice your answer, the concern is as @jarPotato states it that I still want to be able to send messages, I just want to disable the processing.

Currently our workaround is that we gathered all listeners/processors classes in a single module, that is imported conditionally based on an environment variable.

The issue with this pattern is that it's quite easy to accidentally import a listener/processor in the wrong module (or fail to catch this in a review), and thus have the wrong instances (web instead of workers) process the jobs.

leonardbinet avatar May 13 '24 14:05 leonardbinet

Same here. Seems like a pretty standard use-case. I've done something similar (set concurrency to 0 based on an Env var), it's got the same drawback as the above approach. Keen to get this built into Nest/Bull

ISNIT0 avatar Jul 29 '24 17:07 ISNIT0