Queue

Low-level queue interface for dispatching workflow and step invocations.

Queue methods live directly on the world object (not nested). They dispatch internal workflow and step invocations to the queue backend.

These methods are used internally by the Workflow SDK to dispatch execution. You do not need to call them in normal operations — use start() to trigger workflows instead. Direct queue access is only needed if you programmatically create a run via world.events.create() with a run_created event and need to kick off its initial execution, or for debugging resumption of a flow or step route.

Import

import { getWorld } from "workflow/runtime";

const world = await getWorld();
// Queue methods are called directly on world — e.g. world.queue()

Methods

getDeploymentId()

Get the current deployment ID. Used internally for routing queue messages to the correct deployment.

const deploymentId = await world.getDeploymentId();

Returns: string — The current deployment ID

queue()

Dispatch a message to a named queue. The message payload is an internal SDK type (WorkflowInvokePayload, StepInvokePayload, or HealthCheckPayload).

const { messageId } = await world.queue(queueName, payload, opts);

Parameters:

ParameterTypeDescription
queueNameValidQueueNameThe queue name (branded string)
messageQueuePayloadInternal SDK payload
optsQueueOptionsOptional — deploymentId, idempotencyKey, delaySeconds, headers

Returns: { messageId: MessageId | null }

createQueueHandler()

Create an HTTP handler that processes messages from a queue. Used to set up the queue consumer endpoint.

const handler = world.createQueueHandler(prefix, callback);

Parameters:

ParameterTypeDescription
prefixQueuePrefixQueue name prefix to match
callback(message, meta) => Promise<void | { timeoutSeconds: number }>Handler called for each message. meta contains attempt, queueName, messageId, requestId.

Returns: (req: Request) => Promise<Response>

  • start() — The standard way to start workflow runs
  • Starting Workflows — Core concepts for workflow invocation
  • Storage — Create events that trigger queue dispatch