# Priority

> Run urgent ready jobs before ordinary work while preserving FIFO order among peers.

Set `EnqueueOptions.priority` when jobs in one queue should not all compete at the same rank.
PostgreSQL claims higher values first, then keeps FIFO order among jobs with the same value.

<Tabs items={["TypeScript", "Python", "Go"]}>
  <Tab value="TypeScript">
    ```ts
    await queue.enqueue("invoice.remind", { invoiceId }, { queue: "billing", priority: 10 });
    ```
  </Tab>
  <Tab value="Python">
    ```python
    queue.enqueue(
        "invoice.remind", {"invoiceId": invoice_id}, EnqueueOptions(queue="billing", priority=10)
    )
    ```
  </Tab>
  <Tab value="Go">
    ```go
    _, err := queue.Enqueue(ctx, "invoice.remind", map[string]any{
        "invoiceId": invoiceID,
    }, workhorse.EnqueueOptions{Queue: "billing", Priority: 10})
    ```
  </Tab>
</Tabs>

Priority is strict. A steady stream of urgent jobs can delay lower-priority work because Workhorse
does not age jobs or reserve capacity between priority classes. Put work that must always progress
on a separate queue with its own capacity.

## Priority follows the job

Retries, durable waits, delays, and manual promotion keep the stored priority because they continue
the same job. Redrive creates a fresh job but copies the source priority, so urgent failed work does
not silently become ordinary work.

Schedule definitions accept `priority` on their job definition. Priority orders only work that is
otherwise admissible; it does not bypass queue pauses, concurrency policies, rate limits, or a
future `runAt`.

The dashboard sorts the task list with higher priority first and shows the stored value in task
details. The System page groups ready work by priority and shows the oldest task in each group, so
operators can see lower-priority work waiting behind urgent arrivals.

In TypeScript, `ScheduleJobDefinition` stores the recurring job's priority before `fireSchedule`
creates an occurrence, so scheduled work enters the ordinary priority order.

## Next

- [Job dependencies](/docs/job-dependencies) — release blocked work into priority dispatch
- [Concurrency policies](/docs/concurrency-policies) — reserve capacity with separate queues
- [Retries](/docs/retries) — run another attempt without changing rank

---

Exact priority bounds and dispatch rules:
[architecture reference](https://github.com/stablemates/workhorse/blob/main/docs/architecture.md#claim).
