FlowJob Interface
In order to create flows, you must use theFlowProducer class. The add method accepts an object with the following interface:
Adding a Flow
Note that the parent queue does not need to be the same queue as the one used for the children.
Accessing Child Results
When the parent job is processed, it is possible to access the results generated by its child jobs. For example, let’s assume the following worker for the child jobs:getChildrenValues method:
Deep Hierarchies
It is possible to add as deep job hierarchies as needed. Here’s an example where jobs depend on each other, allowing serial execution:The order of processing would be:
chassis, wheels and finally engine.Job Getters
There are several methods available to get jobs related to a flow:Get Dependencies
Get all the direct dependencies (children) of a given job:Get Dependencies Count
Get all the different counts of children by type:Get Children Values
Get all the values produced by the children of a given job:Parent Key Property
A new property is available in theJob class, parentKey, with a fully qualified key for the job parent.
Waiting Children State
Parent jobs that have not yet had their children completed will be in the “waiting-children” state:Queue Options
You can provide queue-specific options for each queue used in the flow:Jobs Removal
BullMQ provides seamless removal functionality for jobs that are part of a flow. When removing a job that is part of a flow, there are several important considerations:- If a parent job is removed, all its children will also be removed.
- If a child job is removed, its parent dependency to said child is also removed, and if the child was the last child in the dependencies list, the parent job will be completed.
- Since a job can be both a parent and a child in a large flow, both 1 and 2 will occur if removing such a job.
- If any of the jobs that would be removed happen to be locked, none of the jobs will be removed, and an exception will be thrown.
Job or the Queue class:
Related Resources
Add Flows in Bulk
Atomically add multiple flows at once
Get Flow Tree
Retrieve job hierarchies with children and grandchildren
Parent Dependencies
Manage complex parent-child job relationships
Fail Parent
Make parent jobs fail when children fail
API Reference
- FlowProducer API Reference
- Job API Reference
- Get Children Values API Reference
- Get Dependencies API Reference
- Get Dependencies Count API Reference
