Cloudflare - v1.3.0
    Preparing search index...

    Class QueueBinding<Body, E>

    Accessor for the Queues producer binding (queues.producers in wrangler.json).

    const jobs = new QueueBinding<EmailJob>() // binding name and send defaults from the configuration layer
    await jobs.send(ctx.env, { to: 'user@example.com', template: 'welcome' })

    Bayu Dwiyan Satria

    1.0.0

    1.0.0

    Type Parameters

    Hierarchy (View Summary)

    Index
    contentType?: QueueContentType

    Default content type applied to sends.

    delaySeconds?: number

    Default delivery delay applied to sends, in seconds.

    settings: () => QueueSettings

    This accessor’s settings, resolved on first read.

    • get name(): string

      The binding name this instance resolves.

      Returns string

      The binding name as declared in wrangler.json.

    • Checks whether the binding is available on the given environment.

      Use this to degrade gracefully when a binding is optional.

      Parameters

      • env: E

        The Worker environment.

      Returns boolean

      true when the binding is present.

    • Reads the queue's current backlog metrics.

      Parameters

      • env: E

        The Worker environment.

      Returns Promise<QueueMetrics>

      The queue metrics.

    • Sends a single message.

      Parameters

      • env: E

        The Worker environment.

      • message: Body

        The message payload.

      • options: QueueSendOptions = {}

        Send options — overrides the configured defaults.

      Returns Promise<QueueSendResponse>

      The send acknowledgement.

      MissingBindingError When the queue binding is absent.

    • Sends a batch of messages in a single call.

      Parameters

      • env: E

        The Worker environment.

      • messages: Body[]

        The message payloads.

      • options: QueueSendBatchOptions = {}

        Batch send options — overrides the configured defaults.

      Returns Promise<QueueSendBatchResponse>

      The batch send acknowledgement.

      Batching is the cheaper path — one call bills as one write regardless of how many messages it carries, up to Cloudflare's batch limits.

    • Applies the configured defaults to send options that do not set them.

      Type Parameters

      • T extends QueueSendOptions | QueueSendBatchOptions

      Parameters

      • options: T

        The caller-supplied send options.

      Returns T

      Send options with defaults filled in.