BullMQ Proxy
  • What is BullMQ Proxy
  • Getting started
    • Architecture overview
    • Using Dragonfly
  • HTTP API
    • Authentication
    • Queues
      • Adding jobs
        • Retries
        • Delayed jobs
        • Prioritized
        • Repeatable
        • LIFO
        • Custom Job IDs
      • Getting jobs
      • Queue's actions
      • Reference
    • Workers
      • Endpoints
      • Adding workers
        • Concurrency
        • Rate-Limit
        • Removing finished jobs
        • Stalled jobs
        • Timeouts
      • Removing workers
      • Getting workers
      • Reference
    • Jobs
      • Jobs' actions
        • Update job progress
        • Add job logs
      • Reference
    • Configuration
    • Debugging
Powered by GitBook
On this page
  1. HTTP API
  2. Queues
  3. Adding jobs

Prioritized

Sometimes it is necessary to process jobs following a priority order. This is easily achieved by setting the "priority" option on the job payload.

The priorities range from 1 to 2 097 152. Where the lowest value has the largest priority, following the same schema used by processes in Unix. A job without priority (or priority 0) will have the highest priority and be processed before any other prioritized job.

The JobOpts interface with the added priority option would look like this:

interface JobOpts {
  priority: number; // an integer between 1 and 2_097_152
  // ... More opts
}
curl --location 'http://mydomain.dev/queues/my-queue/jobs' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer my-secret-token' \
--data '[{
	  "name": "paint-red",
          "data": {},
          "opts": {
            "priority": 5
          }
         },
         {
	  "name": "paint-black",
          "data": {}
         } 
]'

The above snippet will add one Job with priority 5, and another without priority. The job named "paint-black" even though it was added after the one called "paint-red" will be processed before, as jobs without priority will be processed before jobs with priority.

PreviousDelayed jobsNextRepeatable

Last updated 1 year ago