Scheduled jobs
A scheduled job (sjb_) is work the platform starts on a timetable: “build the daily sales
rollup at 02:00”, “close stale carts every 15 minutes”. At each due time the platform fires the
job: it records an instance (sji_) and sends a signed POST to the job’s target URL. The
receiving application does the work and, if the job asks for it, reports back when it has finished.
What a job defines
Section titled “What a job defines”| Field | Meaning |
|---|---|
code, name, description |
Identity. Usually declared in the application’s code and pushed with definition sync. |
crons |
One or more cron expressions. The job fires at the latest due slot across all of them. |
timezone |
The IANA time zone the crons are read in (Europe/Berlin). Default UTC. |
targetUrl |
Where each firing is sent. |
payload |
Optional JSON passed with every firing. |
tracksCompletion |
When true, the receiver reports completion and the instance stays open until it does. |
concurrent |
Whether firings may overlap (default false). Passed to the receiver, which enforces it; the platform does not. |
timeoutSeconds |
The platform’s HTTP timeout for the call (default 10 seconds, at most 300) and the time budget passed to the receiver. |
deliveryMaxAttempts |
How many times a firing is sent before it counts as undeliverable. Default 3. |
status |
ACTIVE, PAUSED (the schedule does not fire) or ARCHIVED. |
| application, client | The owning application (whose service account signs the firings) and, optionally, a client. |
Cron: six fields, seconds first
Section titled “Cron: six fields, seconds first”A cron expression has six fields:
second minute hour day-of-month month day-of-week| Expression | Fires |
|---|---|
0 0 2 * * * |
Every day at 02:00:00 |
0 */15 * * * * |
Every 15 minutes, on the minute |
0 30 9 * * MON-FRI |
09:30:00 on weekdays |
Ranges (1-5), lists (1,15), steps (*/10) and month and day names are accepted. Day-of-week runs
from 0 (Sunday) to 6 (Saturday). The cron reference has the full syntax.
How firings are computed
Section titled “How firings are computed”The scheduler looks at each active job and finds the latest slot due since the job last fired. If
there is one, it creates an instance for that slot and records it as the job’s last firing.
FC_SCHEDULED_JOB_POLL_SECONDS (30) is the longest the poller sleeps, not its resolution: it
wakes early for the next due slot, so a schedule faster than 30 seconds (down to one second) fires on
time. The poll interval also bounds how soon new or edited jobs are noticed. A firing reaches its
target a few seconds after its slot (the dispatcher runs every 5 seconds).
Missed slots are skipped, not replayed. After an outage, a job that should have fired six times
fires once, for the most recent slot. Work that must cover the gap should look at the instance’s
scheduledFor and the previous run.
Exactly one firing per slot
Section titled “Exactly one firing per slot”Each (job, slot) is claimed in the database, in a msg_scheduled_job_ticks table, in the same
transaction that creates the instance. A slot therefore fires once, even if two platform nodes
both believe they are the leader (a failover overlap, a split brain). With FC_STANDBY_ENABLED the
scheduler also holds a Redis leader election so that only one node does the work; the database claim
is the guarantee that does not depend on it.
Instances
Section titled “Instances”Every firing, by the schedule or by hand, is an instance with its own history:
stateDiagram-v2 [*] --> QUEUED: fired (cron or manual) QUEUED --> IN_FLIGHT: sent IN_FLIGHT --> DELIVERED: receiver answered 2xx IN_FLIGHT --> QUEUED: failed, attempts left, or 429 IN_FLIGHT --> DELIVERY_FAILED: attempts used up, or rejected DELIVERED --> COMPLETED: receiver reports completion
A fired instance is QUEUED; the dispatcher (every 5 seconds) sends it and marks it IN_FLIGHT. Any
2xx makes it DELIVERED, which is final unless the job tracks completion; then the receiver’s
report makes it COMPLETED, with a completion status of SUCCESS or FAILURE and an optional
result. An instance that cannot be delivered ends DELIVERY_FAILED.
| The receiver answers | The instance |
|---|---|
2xx |
DELIVERED |
429 |
Back to QUEUED, not sent again before Retry-After (30 seconds when absent, at most an hour). No attempt is spent. |
422 with FlowCatalyst-Outcome: reject |
DELIVERY_FAILED at once |
| Anything else, or no answer within the job’s timeout | Another attempt on a later dispatch round, up to deliveryMaxAttempts, then DELIVERY_FAILED |
The platform waits for the job’s timeoutSeconds (10 seconds when the job sets none,
FC_SCHEDULED_JOB_HTTP_TIMEOUT_SECONDS; capped at FC_SCHEDULED_JOB_HTTP_TIMEOUT_MAX_SECONDS, 300), so a
receiver should accept the firing, answer 202, and do the work in the background. The SDK runners
do exactly that.
The firing request
Section titled “The firing request”The firing is a JSON POST:
| Field | Meaning |
|---|---|
jobId, jobCode |
Which job |
instanceId |
This firing; use it for completion, logs and idempotency |
scheduledFor |
The cron slot (absent for a manual firing) |
firedAt |
When the instance was created |
triggerKind |
CRON or MANUAL |
correlationId |
Present when the firing was started with one |
payload |
The job’s payload |
tracksCompletion, concurrent, timeoutSeconds |
The job’s settings, for the receiver to apply |
It is signed exactly like a dispatch-job delivery (X-FlowCatalyst-Signature over the timestamp and
the raw body, plus a bearer token; see delivery), with one
difference: the signer is always the owning application’s service account. A job with no
application is delivered unsigned.
Acknowledgement and overlap
Section titled “Acknowledgement and overlap”When tracksCompletion is true, the receiver reports the outcome with
POST /api/scheduled-jobs/instances/{instanceId}/complete and can append progress lines with
.../log. Until it reports, the instance stays DELIVERED and the job shows as running, rather than
silently looking finished.
The platform does not prevent overlapping firings: it fires every slot whatever the previous
instance is doing. It passes concurrent to the receiver, and the SDK runners enforce it: for a job
with concurrent: false they take a lock per job code, and a firing that finds the lock held returns
without running the handler (reporting a failure with reason lock-held when the job tracks
completion).
Firing by hand, and by the application
Section titled “Firing by hand, and by the application”- From the console or the API,
POST /api/scheduled-jobs/{id}/firecreates aMANUALinstance, optionally with acorrelationId. A paused job can be fired this way; an archived one cannot. - By the owning application. An application’s service account (through the built-in application-service role) can look up and fire the scheduled jobs of its own application, and no others. This lets an application run “now” what is otherwise scheduled, for example after an import.
Retention
Section titled “Retention”Instances and their logs are kept for 30 days (FC_STREAM_PARTITION_RETENTION_DAYS_SCHEDULED_JOBS),
shorter than events and dispatch jobs: firing history is operational, not business, record. Because
the tables are partitioned by month, data is dropped a whole month at a time.
Why scheduled jobs are not dispatch jobs
Section titled “Why scheduled jobs are not dispatch jobs”A firing is not a message to fan out to subscribers: it is “time for this owner to do this”, sent to one target. It needs no pool, ordering or subscription, but it does need what dispatch jobs do not have: a schedule, a per-run history, completion reporting and overlap control. Keeping it on its own short path also means a busy messaging pipeline never delays the nightly run.
Read next
Section titled “Read next”- Run work on a schedule: receive firings, acknowledge them, fire on demand.
- Cron syntax.
- Scheduled-job scheduler: the firing and dispatch loops in detail.
- Go SDK scheduled jobs.
- Delivery: the signature scheme firings share.