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

Adding jobs

The most basic operation in BullMQ is adding a job. A job is simply a data structure that has a name, some custom data and options. Jobs are added posting a JSON object to the /queues/:queue-name endpoint. The endpoint accepts an array of jobs, if sending a standalone job do not forget to wrap it in an array.

Posting jobs is an atomic operation, either all jobs or none will be added to the queue, so if the call fails for any reason, you can be certain that no jobs were added at all.

The JSON object must follow this interface:

interface Job {
  name: string;
  data: any;
  opts?: JobOpts;
}

Lets add the simplest possible job:

curl --location 'https://myproxy.dev/queues/my-queue/jobs' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer my-secret-token' \
--data '[{
	"name": "paint-red",
        "data": {},
        }]'

Note how we wrap the job in an array, as we are only sending one job in this example.

The call should succeed and return the complete Job as a Json object with all the defaults as it is stored in BullMQ:

[
  {
    "name": "paint-red",
    "data": {},
    "opts": { "attempts": 0, "delay": 0 },
    "id": "116",
    "progress": 0,
    "returnvalue": null,
    "stacktrace": null,
    "attemptsStarted": 0,
    "attemptsMade": 0,
    "delay": 0,
    "timestamp": 1708597320043,
    "queueQualifiedName": "bull:my-test-queue"
  }
]

There are obviously many more advanced jobs and features which we will cover in the next pages.

PreviousQueuesNextRetries

Last updated 1 year ago