When a job handler throws an exception, Proletarian doesn’t immediately discard the job. Instead, it calls your retry strategy function to determine how — and whether — the job should be rescheduled. This lets you configure fine-grained retry behavior per job type, per exception type, or based on information embedded in the exception itself.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/msolli/proletarian/llms.txt
Use this file to discover all available pages before exploring further.
What Triggers Retry Logic
Proletarian only invokes the retry strategy forjava.lang.Exception and its subclasses. Other Throwable subtypes — most notably java.lang.Error (e.g. OutOfMemoryError, StackOverflowError) — are not caught by the retry machinery. They propagate up the call stack and cause the worker thread to log a ::job-worker-error event, which by default stops the worker entirely.
The Retry Strategy Function
Set the:proletarian/retry-strategy-fn option on create-queue-worker to provide a retry strategy. The function receives two arguments:
job— a map with the job’s attributes (same keys as advanced handler mode)exception— thejava.lang.Exceptionthat was thrown
nil (meaning no retry).
The Retry Strategy Map
| Key | Type | Description |
|---|---|---|
:retries | integer ≥ 0 | Maximum number of retries. Total attempts = :retries + 1. |
:delays | vector of integers | Milliseconds to wait before each retry. If fewer delays are provided than retries, the last value is repeated for all remaining retries. |
Examples
nil is the default behavior. If you do not supply :proletarian/retry-strategy-fn, Proletarian uses (constantly nil), which means every failing job is immediately moved to the archive as a failure.
A retry delay is a minimum wait time, not a precise schedule. The actual retry time may be later than specified, depending on the configured
:proletarian/polling-interval-ms and how many jobs are ahead of this one in the queue.Configuring Retry Strategy on the Worker
Handling Permanently Failed Jobs
When a job exhausts all of its retries, Proletarian:- Moves the job to the
archived_jobtable with a:failurestatus. - Calls the function you provided as
:proletarian/failed-job-fn.
The Failed-Job Function
The function receives the same two arguments as the retry strategy function:job— the full job map (:proletarian.job/job-type,:proletarian.job/payload,:proletarian.job/job-id,:proletarian.job/queue,:proletarian.job/enqueued-at,:proletarian.job/process-at,:proletarian.job/attempts)exception— the exception from the final failing attempt
failed-job-fn:
- Alerting — log at
ERRORlevel or send a notification to Sentry, PagerDuty, etc. - Domain state updates — mark an order, payment, or user record as failed so the application can surface the error to the end user.
- Dead-letter queue — write the job details to a separate table for manual inspection and replay.
Archived Job Status
Both successfully completed jobs and permanently failed jobs end up in thearchived_job table (default: proletarian.archived_job). The status column distinguishes them:
| Status | Meaning |
|---|---|
:success | Handler completed without throwing |
:failure | Handler exhausted all retries |
