Queues
A queue gives each message to one worker at a time, and delivers it again until a worker acknowledges it.
A queue holds messages for a pool of workers, the processes that do the work. Nova gives each message to one worker at a time, under a claim that lasts until a deadline. The worker acks the message when the work is done. If the worker fails or never answers, Nova delivers the message again.
A worker asks for messages, and gets one claim for each:
curl -s -X POST 'localhost:8080/v1/queues/apps/emails/claims?max=1&wait=5s'{
"claims": [
{
"claim": "AaIEdM0ne2Kdf/qohRvl4QAAAAAAAAAAAAAAAQAAAAAAAAABAAABogR1Q+U=",
"message_id": "01a20474-cd79-719a-a49e-d83831dd0f97",
"body": "welcome",
"routing_key": "user-42",
"attempt": 1,
"deadline_ms": 1795371123685,
"max_deadline_ms": 1795414293685,
"range": "01a20474-cd27-7b62-9d7f-faa8851be5e1",
"seq": 0
}
]
}claim is the token the worker passes back to ack the message. deadline_ms is when Nova gives the message to another worker if this one has not answered, 30 seconds after delivery by default. attempt is 1 on the first delivery and grows by one after each failed one. max_deadline_ms is the latest the worker can move the deadline to, and range and seq say where the queue stores the message.
Send, claim, and ack
A sender adds messages under a routing key, such as a user or tenant id. A send is stored before it returns, in the order given. Messages with the same key are stored together, and Nova shares its workers fairly across keys, so a busy key does not hold up the others. See fairness.
A worker settles each claim in one of three ways:
| Call | Meaning |
|---|---|
| Ack | The work is done. Nova never delivers the message again. |
| Nack | The attempt failed. Nova delivers the message again after a wait. |
| Extend | The work needs more time. The deadline moves, up to 12 hours after delivery. |
A claim that reaches its deadline counts as a failed attempt, like a nack. Delivery and claims explains every way a claim ends.
Delivery is at least once
Nova delivers a message until a worker acks it, the message runs out of attempts, or it expires. A message that keeps failing is tried five times by default, then moved to the queue's dead-letter stream, where you can read it and send it back. A message expires 4 days after it is sent by default, whether or not it was delivered.
A worker can receive the same message twice, for example after it crashes or misses a deadline. Make the work safe to repeat. Every delivery carries the message's id, message_id, which stays the same across attempts, so a worker can recognize a repeat. When a message is delivered twice lists every case.
Two kinds of queue
You choose a queue's kind when you create it, and it never changes.
standard | key_ordered | |
|---|---|---|
| Order | None | Each routing key's messages, in the order sent |
| Messages out per key at once | Any number, or at most key_concurrency | One |
| A failed message | Goes back in the queue after its wait | Is retried before the key's later messages |
| Delayed delivery | Supported | Refused |
| Use when | The work for one key can run in any order. This is the default choice. | One key's messages must be processed in order, such as the changes to one account |
A key-ordered queue costs throughput on a busy key, and one message that keeps failing holds up its key. See ordering.
What you choose
Every setting has a default, so a queue needs only its kind. These are the choices that change how it behaves:
| Setting | Default | Decides |
|---|---|---|
Claims mode, claims | memory | Whether claims survive a node failure. Fixed at creation. See delivery and claims. |
Dedup policy, dedup | memory | Whether a repeated send with the same idempotency key is recognized after a node failure. See idempotent sends. |
concurrency, key_concurrency | Unbounded | How many claims can be out at once, in the queue and per key. See fairness. |
Retry policy, retry | 5 attempts, waits of 1 s doubling up to 60 s | When a failed message is tried again, and when it is dead-lettered. See retries. |
claim_ttl_ms | 30 s, at most 12 hours | A claim's deadline |
message_ttl_ms | 4 days, at most 14 days | How long a message is kept |
The queue API lists every setting and when a change applies.
A queue is also a stream
A queue stores its messages as the records of a scalable stream at the queue's address. You can read that address like any stream, and the read does not change delivery. It shows every stored message, including those already acked. On a standard queue, it also shows the copy Nova stores each time it retries a message. Nova keeps the message's id, attempt, and routing key in headers that begin with nova-:
{
"seq_num": 2,
"timestamp_ms": 1795371095044,
"body": "receipt",
"headers": [
{
"name": "nova-message-id",
"value": "01a20474-cd79-71a5-bd7d-1c3b3d2db5e6"
},
{
"name": "nova-routing-key",
"value": "user-42"
},
{
"name": "nova-attempt",
"value": "2"
},
{
"name": "nova-sent-at",
"value": "1795371093369"
}
],
"range": "01a20474-cd27-7b62-9d7f-faa8851be5e1"
}You can create a queue only at an address that holds no stream. On a queue's address, the stream operations that would break delivery are refused with 409 and "reason": "queue_address": fence, trim, delete, and reconfigure. Use the queue's own operations instead, such as purge and delete queue.
Clients
| Operation | Go and TypeScript, over gRPC | HTTP, from an SDK or curl | nova CLI |
|---|---|---|---|
| Create, update, delete | Yes | Yes | No |
| Get, list | Yes | Yes | Yes |
| Send | Yes | Yes | No |
| One-shot claim, ack, nack, extend | Yes | Yes | No |
| Run a worker | Yes | No | No |
| Read dead letters | Yes | No | No |
| Replay dead letters, purge | Yes | Yes | Yes |
A worker holds a gRPC connection to each node that delivers the queue, so it cannot run through the Gateway or in a browser. Through the Gateway, take messages with one-shot claims. From a shell, the nova queue commands list, show, purge, and replay queues.
How it works: Queues on streams.