Queue commands

Queue commands

The nova commands that list and show queues, purge their messages, and replay their dead letters.

The queue commands look after queues that an application created. They list a bucket's queues, print one queue's settings and where it is served, remove every message, and send dead letters back. A dead letter is a message that used up its attempts, or that a worker gave up on. The CLI cannot create, change, or delete a queue, or send and claim messages. Use an SDK or the API for those. Each command needs a server address from --addr or NOVA_ADDR, as Connect explains.

export NOVA_ADDR=localhost:7781
CommandDoesGrant
nova queue listPages through a bucket's queueslist
nova queue getPrints a queue's settings, open ranges, and the nodes that deliver themread
nova queue purgeRemoves every message, without askingtrim
nova queue replay-dead-lettersSends the oldest dead letters to the queue againappend

The examples ran on a four-node cluster, so the delivering nodes are 127.0.0.1:8351 to 127.0.0.1:8354. Every command here takes --output json; see Output for its shape.

nova queue list

Prints one page of a bucket's queues, in key order.

nova queue list [options] <bucket | nova://bucket>

List a bucket's queues

nova queue list demo
ADDRESS             KIND         CLAIMS     RANGES  DISPATCHERS
nova://demo/emails  standard     memory     1       1
nova://demo/ledger  key_ordered  persisted  2       2

KIND is standard or key_ordered, and CLAIMS says whether claims live in the delivering node's memory or are persisted. RANGES counts open ranges, and DISPATCHERS counts the distinct nodes delivering them.

Page through the queues

nova queue list demo --limit 1
ADDRESS             KIND      CLAIMS  RANGES  DISPATCHERS
nova://demo/emails  standard  memory  1       1

Next cursor: 01a2048d-60e4-70cb-acb1-f3987a55c0e4 (pass with --cursor)

Pass the cursor back as printed. --prefix led keeps only queues whose key starts with led. A bucket with no queues prints No queues found.. With --output json, each item carries every setting queue get prints, in milliseconds, and the page ends with next_cursor.

--prefixDefaultNone
Only queues whose key starts with this
--limitDefault100
Queues a page, at most 100
--cursorDefaultNone
The Next cursor the previous page printed
--outputDefaulttext
json prints the page as one object

The concept is Queues. The same task is List queues with an SDK and List a bucket's queues over the API.

nova queue get

Prints one queue's settings, its open ranges, and the node delivering each.

nova queue get [options] <nova://bucket/key>

Show a queue

nova queue get nova://demo/emails
nova://demo/emails
  Kind:                                   standard
  Claims:                                 memory
  Dedup:                                  memory
  Concurrency:                            unbounded
  Key concurrency:                        unbounded
  Claim ttl:                              30s
  Message ttl:                            96h0m0s
  Dead-letter ttl:                        336h0m0s
  Max attempts:                           3
  Retry wait:                             1s, then ×2 each time, at most 1m0s
  Dead-letter range:                      01a2048d-60e4-70e6-b203-ee23bb76a12f
  Dispatchers:                            127.0.0.1:8354
  Ranges:                                 1 open
    01a2048d-60e5-7547-a7fe-122892688bc7  127.0.0.1:8354

Retry wait is the wait before the second attempt, how it grows, and its longest value. The last lines name each open range and the address of the node that delivers its messages. Use them to find which node's logs to read when one range lags.

A stream address fails with exit code 1:

nova: client: stream not found: star: not a queue: demo/orders
--outputDefaulttext
json prints the queue as one object, durations in milliseconds

The concept is Queues, and Queue settings lists every setting. The same task is Read a queue with an SDK and Get a queue over the API.

nova queue purge

Removes every message from a queue. The queue, its settings, and its dead letters stay.

nova queue purge [options] <nova://bucket/key>

Purge a queue

nova queue purge nova://demo/emails
purged nova://demo/emails: 4 messages removed

After one more message was sent, a second purge with --output json:

{
  "action": "purged",
  "address": "nova://demo/emails",
  "purged": 1
}

The command does not ask for confirmation. Use it to drop a backlog you no longer want, such as messages a bad release sent. A purge visits every open range. When one range's node cannot be reached, the command fails with nova: purge of <address>: removed <n> messages before failing: and the cause. Run it again once the node is back. A second purge removes only what is left.

A purge can need the admin grant

When a range's messages are stored on a different node from the one that delivers them, the purge fails with PermissionDenied … admin verb requires the nova:admin marker, even with a trim grant. Run it with a token that holds nova:admin.

--outputDefaulttext
json prints action, address, and purged

The concept is Queues. The same task is Purge a queue with an SDK and Purge a queue over the API.

nova queue replay-dead-letters

Sends a queue's oldest dead letters to the queue again. Each starts over as a first attempt.

nova queue replay-dead-letters [options] <nova://bucket/key>

Replay the dead letters

After you fix what made the messages fail:

nova queue replay-dead-letters nova://demo/emails --limit 100
replayed 1 dead letters to nova://demo/emails

Replay every dead letter, in a script

nova queue replay-dead-letters --output json nova://demo/emails
{
  "action": "replayed",
  "address": "nova://demo/emails",
  "replayed": 0,
  "more": false
}

more is true while dead letters remain, so a script repeats the command until it is false. Each run takes at most --limit, oldest first, and removes the ones it sent from the dead letters. This loop replays them all:

while nova queue replay-dead-letters --output json nova://demo/emails \
  | jq -e .more > /dev/null; do :; done

It prints nothing. It stops after the run that prints "more":false, and also when the command fails, because jq then reads no input.

A failed replay sends the same messages again

The dead letters can be stored on a different node from the one that delivers the queue. Then the replay sends them and fails with PermissionDenied … admin verb requires the nova:admin marker, even with an append grant. The messages it sent stay in the dead letters, so running it again sends them a second time. Run it with a token that holds nova:admin.

--limitDefault100
The most dead letters to send, at most 1,000
--outputDefaulttext
json prints action, address, replayed, and more

The concept is Delivery and claims. The same task is Replay dead letters with an SDK and Replay dead letters over the API.

On this page