Delivery and claims
A claim gives one message to one worker until a deadline, and Nova delivers it again unless acked.
A claim is one delivery of a message to one worker. It lasts until its deadline, and the worker ends it with an ack, a nack, or an extend. Unless the worker acks, Nova delivers the message again. A worker that nacks a message and claims again after the wait receives the same message as its next attempt:
curl -s -X POST localhost:8080/v1/queues/apps/emails/claims/nack -d "{\"claim\": \"$CLAIM\"}"
curl -s -X POST 'localhost:8080/v1/queues/apps/emails/claims?max=1&wait=5s'{
"claims": [
{
"claim": "AaIEdM0ne2Kdf/qohRvl4QAAAAAAAAACAAAAAgAAAAAAAAABAAABogR1TB0=",
"message_id": "01a20474-cd79-71a5-bd7d-1c3b3d2db5e6",
"body": "receipt",
"routing_key": "user-42",
"attempt": 2,
"deadline_ms": 1795371125789,
"max_deadline_ms": 1795414295789,
"range": "01a20474-cd27-7b62-9d7f-faa8851be5e1",
"seq": 2
}
]
}The message_id is the one the first attempt carried. The position changed: the first attempt was seq 1, and this one is seq 2, because a standard queue stores a new copy of a message each time it retries it. A key-ordered queue retries the message at the same position. Track messages by message_id.
How a claim ends
| End | What Nova does |
|---|---|
| Ack | Marks the message done. It is never delivered again. |
| Nack | Counts a failed attempt and delivers the message again after the retry policy's wait: 1, 2, 4, then 8 seconds by default. After the last attempt, 5 by default, it moves the message to the dead-letter stream. |
| Extend | Moves the deadline. No claim lasts past its max deadline, 12 hours after the message's delivery. |
| The deadline passes | The same as a nack |
| The queue takes the claim back | Delivers the message again as the same attempt. With memory claims this happens when a node stops or a range moves. A purge also takes claims back, and its messages are gone. |
The deadline is the claim TTL after delivery: 30 seconds by default, set per queue, and per claim when a worker asks. A nack can name its own wait, or send the message straight to the dead-letter stream. A nack marked unattempted, for a message the worker never started, costs no attempt, up to three times a minute and within 15 minutes of the first. Retries and dead letters covers each option.
The two modes
A queue's claims mode sets where Nova records which messages are out with workers. With memory, the default, the record lives in the memory of the node that delivers the range. With persisted, each claim is also a row in the metadata store. The mode changes what happens to claims when a node stops or a range moves to another node. A worker that crashes or misses a deadline causes a redelivery in both modes.
memory | persisted | |
|---|---|---|
| A node stops in order: drain, restart, range move | Claims are taken back, and the next node delivers their messages again | Claims stand. The next node waits for each ack or deadline. |
| A node dies | Messages out with workers are delivered again, plus those acked in the last 250 ms, at most 1,024 | Claims stand, and every answered ack is kept |
| An ack sent after the range moved | Refused seat_moved. The work is repeated. | Accepted by the new node |
| The metadata store is unreachable | Delivery continues | Delivery stops until the store returns |
| A claim that is no longer valid | Refused not_held | Refused claim_gone |
| Each delivered message costs | No write of its own. The node saves its progress in batches. | A metadata write at delivery and another at the ack |
Use memory when repeating a message is cheap: the work is idempotent, or the worker checks the message id. Use persisted when a repeat is expensive or visible, such as charging a card, sending a notification, or a long job. Each persisted delivery and ack waits for a write to the metadata store, so measure the throughput with your own load. Operate › Queues lists the writes.
With persisted claims, the node honors an ack, nack, or extend that reaches it before the deadline, even if it handles the call after it. After a range moves, a claim's max deadline still counts from its first delivery.
The claims mode does not cover repeated sends. Whether Nova recognizes a repeated idempotent send after a node failure depends on the queue's separate dedup policy.
When a message is delivered twice
Delivery is at least once in both modes. These are all the cases that repeat a message:
| Case | Memory claims | Persisted claims |
|---|---|---|
| A worker crashes, or finishes after its deadline | Delivered again | Delivered again. A late ack is refused claim_gone. |
| A worker's ack is lost on the way | Delivered again at the deadline | Delivered again at the deadline |
| A node stops in order: drain, restart, range move | Messages out with workers are delivered again | No repeat |
| A node dies | Messages out with workers, plus up to 250 ms or 1,024 of the latest acks | No repeat |
| A range moves and the old node has not learned it yet: 100 to 250 ms in tests, at most 5 seconds | Messages both nodes deliver | Messages both nodes deliver. Only the new node's claim settles them. |
| A noisy key is moved to its own range | That key's messages out at the move | That key's messages out at the move |
| A replay of dead letters is interrupted | A replayed message | A replayed message |
| A sender repeats a send without an idempotency key | Both copies | Both copies |
A sender repeats an idempotent send after a range move, with memory dedup | Both copies | Both copies |
Every delivery carries the message's id, the same on every attempt. Use it to recognize a repeat, and make the work safe to run twice.
During a rolling upgrade from an older build, an older node can still replace its successor's claim rows; see rolling upgrades.
Refusals
When the queue will not act on an ack, nack, or extend, it refuses the claim and says why. An ack lists its refusals in its answer:
{
"refused": [
{
"claim": "AaIEdM0ne2Kdf/qohRvl4QAAAAAAAAACAAAAAgAAAAAAAAABAAABogR1TB0=",
"refusal": "not_held",
"reason": "queue: the claim is not held: range 01a20474-cd27-7b62-9d7f-faa8851be5e1 position 2"
}
]
}| Refusal | What happened | What to do |
|---|---|---|
not_held | The claim was settled already, or it expired and the message was delivered again | Nothing. Work that finished after the deadline may be done twice. |
seat_moved | Another node delivers the range now, or delivery restarted. The message will be delivered again. | Drop the claim. Work done under it may be done twice. |
claim_gone | The message was purged. With persisted claims, the claim may also have been settled, retried, or taken over by a new node. | Drop the claim. Unless it was settled or purged, the message comes back. |
malformed | The bytes are not a claim, or a TTL or wait is out of bounds. Nothing was done. | Fix the call. The claim still stands. |
past_max_deadline | An extend would pass the max deadline. The claim keeps its deadline. | Extend by less, or let the claim expire |
After not_held, seat_moved, or claim_gone, the claim is no longer yours, and another worker may already hold the message. Do not send the call again. A claim on a purged message is refused seat_moved until a worker next asks for that range's messages, and claim_gone after. Either way, the purged message is not delivered again.
Run a worker shows how each SDK reports a refusal, and the claims API gives the status codes.
Refusals while a range moves
On a queue with persisted claims, an ack or nack that reaches a range's old node just after the range moved can be refused before the claim's deadline. The queue then settles or delivers the message without this worker. Refusals while a range moves lists which refusal each call gets.
The mode is fixed
You set claims when you create the queue. An update that leaves it out keeps the queue's mode, and one that names the other mode is refused with 400:
{
"error": "queue: apps/emails: a queue's claims mode is fixed at creation"
}A node keeps a range's claims in one mode for as long as it delivers the range, so a switch would lose track of the claims already out. To change modes, create a new queue and move your senders and workers to it.
How it works: Queues on streams.