Dispatch jobs
A dispatch job (djb_) is one delivery of one payload to one target, together with the record
of every attempt to deliver it. It is the unit the whole delivery side works in: the scheduler
publishes jobs, the router paces them, the delivery callback delivers them, and operators find,
retry and cancel them.
Where jobs come from
Section titled “Where jobs come from”| Source | How | The job’s code |
|---|---|---|
| An event | The fan-out creates one job per active subscription that matches the event | The event type, for example orders:sales:order:placed |
| An application | Directly, through the outbox (DISPATCH_JOB rows) or POST /api/dispatch-jobs and /batch |
A code the application chooses, starting with its own application code, for example orders:warehouse:pick-list:send |
| A function | fn.dispatch, to call another function of the same application |
The function’s code, by default {app}:function:{name}:dispatch |
| An ingestion | Each record read from a source becomes a job (or an event) | The ingestion’s target code |
A directly created job names its own target URL, payload and content type, and optionally a connection, a dispatch pool, a message group and an idempotency key. It needs no subscription: use it when the producer knows exactly which endpoint to call, and still wants the platform’s retries, ordering, pacing, signing and audit trail.
The code is how jobs are searched and filtered: the list filters eventType and eventTypes work
on it, for event-raised and direct jobs alike.
What a job holds
Section titled “What a job holds”| Group | Fields |
|---|---|
| Identity | id, code, kind (EVENT or TASK, descriptive only), descriptor (a display name, resolved when the job is read: see below), externalId, metadata |
| Where it goes | targetUrl, dataOnly, payload, payloadContentType |
| Where it came from | eventId, subscriptionId, source, subject, correlationId, clientId |
| How it is delivered | dispatchPoolId, messageGroup, mode, sequence, queue (DEFAULT or HIGH_PRIORITY), timeoutSeconds (default 30), maxRetries (default 3) |
| Where it stands | status, attemptCount, lastError, scheduledFor, lastAttemptAt, completedAt, durationMillis |
The descriptor and the descriptor catalogue
Section titled “The descriptor and the descriptor catalogue”A job’s descriptor is a display name for the list and detail views. The platform does not copy the
subscription’s name onto each job when an event fans out. It resolves the name when a job is read,
with one batched lookup per page: for a job raised by a subscription, the subscription’s name;
otherwise the name the descriptor catalogue holds for the job’s code; otherwise the descriptor
stored on the job (older jobs, and jobs whose sender still sends one); otherwise nothing, and the
code stands in. POST /api/dispatch-jobs still accepts and stores a descriptor.
The catalogue gives a direct job a name without repeating it on every row. It holds one entry per
four-segment code (application:subdomain:aggregate:action), with a name and an optional
description; the code cannot change after it is created. Entries are managed through
/api/dispatch-job-descriptors (list, create, get, update, delete: see the
API reference), under the permissions
platform:messaging:dispatch-job-descriptor:view, :create, :update and :delete, and on the
console’s Job Descriptors page under Messaging. The built-in Messaging Administrator role holds all
four and Platform Viewer holds view. Nothing reads the catalogue on the write path, so adding or
renaming an entry changes how existing jobs are named at once.
The lifecycle
Section titled “The lifecycle”stateDiagram-v2 [*] --> PENDING: created PENDING --> QUEUED: scheduler publishes a pointer QUEUED --> PROCESSING: delivery callback claims it PROCESSING --> COMPLETED: consumer answered 2xx PROCESSING --> PENDING: retry later, deferral PROCESSING --> FAILED: attempts used up, or refused QUEUED --> PENDING: group held, or stale FAILED --> PENDING: requeue CANCELLED --> PENDING: requeue COMPLETED --> PENDING: redrive PENDING --> CANCELLED: cancel QUEUED --> CANCELLED: cancel PROCESSING --> CANCELLED: cancel FAILED --> CANCELLED: cancel FAILED --> COMPLETED: mark completed
A job is born PENDING. The dispatch scheduler publishes a pointer to it and marks it QUEUED. The
delivery callback claims it (PROCESSING), delivers, and records the outcome: COMPLETED, back to
PENDING with a later time for a retry, or FAILED. Operators can requeue, redrive, cancel and
complete jobs, as the lower half of the diagram shows.
| Status | Meaning |
|---|---|
PENDING |
Waiting to be published. It may carry a future scheduledFor (sitting out a retry or a deferral), or be held: by a paused connection, or behind a failed job in a BLOCK_ON_ERROR group. |
QUEUED |
A pointer is on the queue; the router has it or will soon. |
PROCESSING |
A delivery attempt is under way. |
COMPLETED |
The consumer accepted it, or an operator marked it handled. Final unless redriven. |
FAILED |
Out of attempts, or refused in a way a retry cannot fix. Waits for an operator, and holds its group if the mode is BLOCK_ON_ERROR. |
CANCELLED |
An operator decided not to deliver it. |
EXPIRED |
The job was not delivered by its expiresAt. Final, no attempt counted, holds no group; an operator can requeue it. See below. |
Only one component writes the status column: the dispatch-job lifecycle. Every transition is a single conditional update that names the statuses it may move from, so a late or duplicate callback can never move a job that has already moved on.
Delay, expiry and pool status
Section titled “Delay, expiry and pool status”An event-raised job gets two absolute times when the fan-out creates it, taken from the subscription and counted from the event’s creation: not_before (delaySeconds) and expiresAt (maxAgeSeconds, 24 hours unless the subscription sets it). Editing the subscription later does not move jobs already raised. A job created directly can carry its own expiresAt.
- Not yet due. The delivery callback answers a job reached before
not_beforewith{"ack": false, "notBefore": ..., "delaySeconds": ...}and the job staysQUEUED; the router redelivers it at exactly that time. One answer holds for at most 5 minutes, so a long delay is a series of holds, the last ending atnot_before. - Expired. A job reached at or after
expiresAtbecomesEXPIRED(“expired: not delivered by …”), is acknowledged and is never attempted. This includes jobs held behind a failedBLOCK_ON_ERRORjob for longer than the limit. A requeue clearsexpiresAt: an operator’s requeue is a delivery now. - Pool status. The scheduler does not claim jobs of a
SUSPENDEDorARCHIVEDpool, and a job of such a pool that is already queued goes back toPENDINGwithout an attempt and waits until the pool isACTIVEagain. New jobs and subscriptions cannot name anARCHIVEDpool (409 POOL_ARCHIVED).
Attempts, retries and backoff
Section titled “Attempts, retries and backoff”Each delivery is an attempt, stored with its number, timings, the response status and body (up
to 64 KiB), an error type (CONNECTION, TIMEOUT, HTTP_ERROR), and a summary of what was sent:
the signing service account’s code, which credential headers went out, the header names, and why a
delivery went out unsigned when it did.
maxRetriesis the number of attempts in all. With the default of 3, a job is tried three times before it fails.- After a failed attempt the job waits according to its
retryStrategy. The default,exponential, waits 5 s, 15 s, 30 s, 60 s, then 120 s for every later attempt;fixedwaits 30 s every time;immediatewaits only for the next scheduler poll. - Some answers fail the job at once:
401or403(the consumer refused the credentials; a retry would send the same ones) and422withFlowCatalyst-Outcome: reject(the consumer says retrying cannot help). - Deferrals do not count. A consumer that answers
2xxwith{"ack": false}, or429, gets the job again later without spending an attempt. The consumer can name the time:{"ack": false, "notBefore": "<RFC 3339>"}(ordelaySeconds), orRetry-Afteras seconds or as an HTTP date. See delivery.
The retryStrategy (exponential, fixed or immediate) is set when a job is created through the
single-job route, POST /api/dispatch-jobs; the batch route and event-raised jobs use exponential.
Recovery without an operator
Section titled “Recovery without an operator”| Situation | What happens |
|---|---|
| The queue message is lost, or the router parked it too long | A job QUEUED for 15 minutes returns to PENDING and is published again. A duplicate copy that turns up later is dropped by the router or skipped by the callback. |
| The platform died during a delivery | The callback’s claim has a lease: the job’s timeout (capped at 2 minutes) plus 30 seconds. A later copy of the message finds the lease run out, takes the claim over and delivers again. |
| No copy of the message comes back | A job PROCESSING for 75 minutes with no outcome returns to PENDING, with the reason in lastError. |
Siblings stranded behind a failed BLOCK_ON_ERROR head |
The router reports them to the platform, which returns them to PENDING; a sweep every 2 minutes catches any it missed. See ordering. |
Operator actions
Section titled “Operator actions”Each write action has its own permission, and each is recorded in the audit log.
| Action | Applies to | Effect |
|---|---|---|
| Requeue (by ids, or by filter with a preview) | PENDING, FAILED, CANCELLED, EXPIRED |
Back to PENDING, due now, with a full set of attempts. QUEUED and PROCESSING jobs are skipped and reported, never an error. |
| Requeue in flight (console, selected jobs, confirmed) | QUEUED, PROCESSING |
The same reset for a job judged stuck. A delivery still under way may land as well as the new one. Never available by filter. |
| Redrive | COMPLETED |
Delivers a job the consumer already accepted. Needs redriveCompleted: true, the literal confirmRedriveCompleted: "REDRIVE", and its own permission (dispatch-job:redrive-completed), which no built-in role lists. |
| Cancel | PENDING, QUEUED, PROCESSING, FAILED |
CANCELLED. A delivery already under way cannot be recalled, but its outcome is then refused, so the job stays cancelled. |
| Mark completed | FAILED |
COMPLETED, for a job handled out of band. |
| Edit payload | PENDING, FAILED |
Replaces the payload (and optionally its content type, at most 256 KiB) without touching status or attempts; requeue it afterwards. The audit row records sizes and digests, not the payload. |
| Sign (preview) | Any | Shows exactly what a delivery would send right now, with a real signature, so the consumer’s verification can be checked against it. |
Why redrive is separate. Sending a completed job again repeats work the consumer already did. Making it a separate, doubly confirmed action with its own permission means a broad “requeue everything that matches” can never repeat completed deliveries by accident.
Reading jobs: the time window
Section titled “Reading jobs: the time window”The list-shaped reads (the list, the raw list, filter options, and the requeue-by-filter preview and
run) are held to a created_at window. Send since and until; send neither and the last 24 hours
are read. A window wider than 31 days (FC_DISPATCH_JOB_MAX_WINDOW_DAYS) is refused with
WINDOW_TOO_LARGE, and every answer says which window it used. Lookups of one job, or of one event’s
jobs, are not windowed.
Why. The job table is partitioned by month and grows with every event. An unbounded list or requeue-by-filter would scan every partition. A window keeps each read to the partitions it needs, and makes the scope of a bulk requeue explicit.
Read next
Section titled “Read next”- Find, requeue, redrive, cancel and edit dispatch jobs.
- Runbook: stuck dispatch jobs and requeue and redrive.
- Delivery, ordering and pools: what
happens to a job between
QUEUEDandCOMPLETED. - Create a dispatch job from a function.
- Dispatch scheduler: how
PENDINGjobs become queued messages. - Decision: time-windowed dispatch reads and explicit redrive.