API Reference · A-0739–A-0740

Job Policies

Control how Priostack handles job deadlines, retries, and timeout boundary events to make your service tasks resilient.

Overview· Workers· Incidents· Versioning· Correlation IDs· Job Policies

Job deadlines

Job deadline field

The deadline is the absolute UTC timestamp by which a job lock must be released (via complete or fail). It is derived from the timeout you pass when activating a job:

deadline = activatedAt + timeout_ms

If a worker holds a job past its deadline without completing or failing it, Priostack releases the lock and the job becomes available for re-polling. This protects against worker crashes and network partitions.

Field (activate request)TypeDefaultDescription
timeoutinteger (ms)30 000Lock duration in milliseconds. Deadline = activation time + timeout.

The deadline is returned in every activated job object. Workers should check it and fail the job gracefully before it expires rather than letting the lock silently release:

// Example: fail job 5 seconds before deadline to leave retry headroom
const msRemaining = new Date(job.deadline) - Date.now();
if (msRemaining < 5000) {
  await failJob(job.key, { retries: job.retries - 1, errorMessage: "Deadline approaching" });
  return;
}
// ... do work ...
await completeJob(job.key, { variables: result });

Retry policy

Job retry configuration

Each job has a retry counter. You set the initial retry count in the BPMN task definition extension or at job completion/failure time. When a worker calls fail, it passes the remaining retries value.

When retries reach 0, Priostack raises an incident and the process pauses at that task. A human or automated runbook must resolve the incident (typically by calling update-retries then resolve).

ScenarioWorker actionResult
Transient error, more retries leftfail with retries: N-1Job re-queued after retryBackoff ms
Permanent errorfail with retries: 0Incident raised immediately
SuccesscompleteProcess advances to next element

Setting retries in BPMN (extension element)

<bpmn:serviceTask id="task_charge" name="Charge payment">
  <bpmn:extensionElements>
    <zeebe:taskDefinition type="payment:charge" retries="3" />
  </bpmn:extensionElements>
</bpmn:serviceTask>

Retry backoff

Pass retryBackoff (milliseconds) in the fail request to delay the next attempt. Use exponential backoff for external API calls to avoid thundering herds:

// Attempt 1: fail with retryBackoff: 2000
// Attempt 2: fail with retryBackoff: 4000
// Attempt 3: fail with retries: 0 → incident
const backoff = Math.pow(2, attemptNumber) * 1000;
await failJob(job.key, {
  retries: job.retries - 1,
  errorMessage: "Stripe rate limit",
  retryBackoff: backoff
});

Timeout boundary events

BPMN timeout boundary events

A non-interrupting or interrupting timer boundary event on a service task lets you react to long-running jobs in the process model itself, without relying solely on job-level retries.

Interrupting vs non-interrupting: An interrupting boundary event cancels the task when it fires. A non-interrupting event triggers a parallel branch while the task continues running.

Common patterns:

PatternConfigurationUse case
Escalation after SLANon-interrupting timer → notification taskNotify a manager if payment hasn't completed in 30 min
Hard deadline cancelInterrupting timer → error end eventCancel order if fulfilment doesn't start within 2 hours
Fallback pathInterrupting timer → alternative service taskSwitch to backup payment provider after 10 seconds

BPMN snippet — interrupting timer

<bpmn:boundaryEvent id="timeout_charge" attachedToRef="task_charge"
    cancelActivity="true">
  <bpmn:timerEventDefinition>
    <bpmn:timeDuration>PT30S</bpmn:timeDuration>
  </bpmn:timerEventDefinition>
</bpmn:boundaryEvent>

When the timer fires, Priostack cancels the job lock, raises an incident for the timed-out job (if configured), and follows the sequence flow from the boundary event to your error-handling path.

See also:   Worker API · Incident management · Troubleshooting guide