method WorkersQueue.prototype.add
WorkersQueue.prototype.add<T>(
name: string,
data: T,
options?: AddJobOptions
): Promise<string>

Enqueues a job.

The returned id is generated here rather than by the platform, because producer.send() resolves to void. It travels inside the message envelope, so the id this returns is the id the processor sees as job.id.

Type Parameters

The payload type

Parameters

name: string

Job name; a processor must be registered under it to consume

data: T

Job payload, serialized as JSON by the platform

optional
options: AddJobOptions

delayMs (converted to whole seconds, rounded up) and maxAttempts (enforced at dispatch, since Cloudflare's max_retries is queue-wide configuration rather than per message)

Return Type

Promise<string>

The job id

Throws

CloudflareUnsupportedError

When delayMs exceeds the configured cap

Usage

import { WorkersQueue } from "cloudflare-plugin/src/index.ts";