bullmq: Flow doesn't follow Queue's default job options
The default job options set on the queue level are not obeyed when enqueuing jobs with the flow producer.
For instance, creating a queue like this:
const queue = new Queue('a-queue', {
connection: redisClient,
defaultJobOptions: {
attempts: 3,
delay: 500,
removeOnComplete: 25,
removeOnFail: 25,
backoff: {
type: 'exponential',
delay: 5000,
},
},
limiter: {
groupKey: 'someId',
},
});
The job dispatched by the flow producer will have the following properties:
{
"attempts": 0,
"delay": 0
}
Is there anything else I should be doing for it to work correctly?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 16 (7 by maintainers)
Commits related to this issue
- chore(release): 1.74.1 [skip ci] ## [1.74.1](https://github.com/taskforcesh/bullmq/compare/v1.74.0...v1.74.1) (2022-02-20) ### Bug Fixes * **flow:** respect defaultJobOptions from queue opts ([#108... — committed to taskforcesh/bullmq by semantic-release-bot 5 years ago
- docs(queues): warn that `defaultJobOptions` don't always work It's very unobvious that `defaultJobOptions` apply to jobs being scheduled only sometimes. If you schedule jobs via a `FlowProducer`, ... — committed to jtomaszewski/docs.nestjs.com by jtomaszewski 2 years ago
Yes, I do use the FlowProducer and that works all fine as described.
My point is: Even the FlowProducer doesn’t work for itself but uses defined queues to process a job, being the parent or the children. And queues are defined somewhere. And queues have some defaultJobOptions. And even a Flow job is a job which gets processed by the queue. And that’s why I expect the executed job to respect the queues defaultJobOptions.
I just ran into the same issue.
Yes, I can pass the options into the job, but is that really the way to go? I’m expecting the job to always respect the default queue options. Why not for flows?
Thx @hicaro for posting some details. That’s exactly my issue.
@manast For me it’s fine passing the options to the flow options when calling
flowProducer.add(). In my case children have a different queue due to different requirements on the backoff logic. That’s why passing it to the constructor doesn’t work for me.Anyway, it’s just confusing since you still run those jobs on a queue. It’s still a job. And that’s why it’s not self explanatory that the default options on the queue doesn’t count for the flow. So if it’s really not possible then it should be properly documented. I’m sure that this doesn’t only confuse me.