Table of Contents

Enum JobState

Namespace
MailFathom.Application.Jobs
Assembly
MailFathom.Application.dll

States where one durable job stands between being enqueued and being finished with.

public enum JobState

Fields

Claimed = 1

A worker holds a lease on the job. It becomes claimable again on its own when that lease expires.

DeadLettered = 3

The work will not be attempted again. The row is terminal and keeps its idempotency key, exactly as a succeeded one does.

A job reaches this either because its failure was permanent, where a second attempt could only reach the same answer, or because it exhausted the attempts it was allowed. Both are the same thing to the queue: work that stops consuming attempts and stops occupying a worker, so one poison message delays nothing else.

It is a state on the row rather than a move to another table, because uniqueness spans the whole table and a row that gave up its key would let permanently failing work be enqueued again forever. What the row keeps beside the key is its attempt count and the classification and reason of the failure that ended it, which is what an operator acts on.

Terminal but not permanent: an operator who has fixed what caused the failure returns the job to Pending, and one who never wants it run moves it to Dropped. Neither happens on its own, which is the whole point of the state — it waits for somebody.

Dropped = 4

An operator decided the work will never be run. The row is terminal and keeps its idempotency key, exactly as a dead-lettered one does.

A state of its own rather than a deleted row, because what an operator did to a job is itself a fact worth keeping: a queue that answered "nothing is dead-lettered" identically for a queue somebody emptied and a queue nothing ever failed in would make the decision invisible the moment it was taken. The row keeps the failure that dead-lettered it, so what was dropped and why it stopped are both still readable.

It is reachable only from DeadLettered. Dropping work that is pending or claimed would race the worker holding it, and there is nothing to decide about a job that has not yet failed.

Pending = 0

The job is enqueued and claimable once its available instant has passed.

Succeeded = 2

The work was done. The row is terminal and keeps its idempotency key, so the same trigger cannot enqueue it again.

Remarks

The members are names the process reads and the stored row carries, and nothing about a state has to be carried with it, so this is an ordinary enum rather than a closed enumeration. It is stored as its name for the reason every other bounded value in this schema is: the row stays readable in an ad-hoc query, and no later member can change what an existing row means.