如何序列化BullMQ作业队列中的作业?我需要下一个作业只有在前一个作业完成后才能执行。我正在使用BullMQ 3。
发布于 2022-07-04 21:42:40
您可以使用FlowProducer创建这类行为。
一个例子是:
const flowProducer = new FlowProducer({connection: {
host: "host_here",
port: 6379
}});
const jobChain = await flowProducer.add({
name:'example',
data: { field: 'value'},
"queueName",
children: [{
name: 'example2', //can be same/different name
data: {field: 'otherValue'},
"queueName", // can be a different queuename
children: ...
}],
});在这里,“示例”作业只有在成功处理"example2“时才会执行。这既与FlowProducer行为有关,也与对工作生命周期的一般理解有关。
https://stackoverflow.com/questions/71865557
复制相似问题