From 07855ad9c84e943b8300df26a2e0304c7535c391 Mon Sep 17 00:00:00 2001 From: Rogger Valverde Date: Tue, 31 Oct 2023 21:23:41 -0700 Subject: [PATCH] docs(retry): extend description (#2164) --- docs/gitbook/guide/retrying-failing-jobs.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/gitbook/guide/retrying-failing-jobs.md b/docs/gitbook/guide/retrying-failing-jobs.md index fc4ff481de..753deca232 100644 --- a/docs/gitbook/guide/retrying-failing-jobs.md +++ b/docs/gitbook/guide/retrying-failing-jobs.md @@ -1,6 +1,6 @@ # Retrying failing jobs -As your queues processes jobs, it is inevitable that over time some of these jobs will fail. In BullMQ, a job is considered failed in the following scenarios: +As your queues process jobs, it is inevitable that over time some of these jobs will fail. In BullMQ, a job is considered failed in the following scenarios: - The processor function defined in your [Worker](https://docs.bullmq.io/guide/workers) has thrown an exception. - The job has become [stalled](https://docs.bullmq.io/guide/jobs/stalled) and it has consumed the "max stalled count" setting. @@ -19,6 +19,10 @@ Often it is desirable to automatically retry failed jobs so that we do not give BullMQ supports retries of failed jobs using back-off functions. It is possible to use the **built-in** backoff functions or provide **custom** ones. If you do not specify a back-off function, the jobs will be retried without delay as soon as they fail. +{% hint style="info" %} +Retried jobs will respect their priority when they are moved back to waiting state. +{% endhint %} + #### Built-in backoff strategies The current built-in backoff functions are "exponential" and "fixed". @@ -81,6 +85,12 @@ const worker = new Worker('foo', async job => doSomeProcessing(), { }); ``` +{% hint style="info" %} +If your backoffStrategy returns 0, jobs will be moved at the end of our waiting list (priority 0) or moved back to prioritized state (priority > 0). + +If your backoffStrategy returns -1, jobs won't be retried, instead they will be moved to failed state. +{% endhint %} + You can then use your custom strategy when adding jobs: ```typescript @@ -128,3 +138,7 @@ const worker = new Worker('foo', async job => doSomeProcessing(), { }, }); ``` + +## Read more: + +- 💡 [Stop Retrying Jobs](../patterns/stop-retrying-jobs.md)