iii-queue worker decouples producers from consumers: a function publishes a message to a named
topic and returns right away, and any function subscribed to that topic processes the message in the
background, with retries and a dead-letter queue (DLQ) for messages that keep failing.
This page is a quick tour. For retry and back-off settings, queue adapters, and the full function
list, see the iii-queue worker docs.
Consuming messages
A function consumes a topic by binding adurable:subscriber trigger to it. The engine runs the
function once per message, passing the published data as the payload. Returning normally
acknowledges the message; throwing nacks it, so it is retried and eventually dead-lettered.
- In a worker, register the consumer function and subscribe it to the topic. If you do not have a
worker yet, scaffold one with
iii worker init, then edit its source:
- Node / TypeScript
- Python
- Rust
- Add the worker to start it:
Publishing a message
With the consumer running, publish to its topic. The engine delivers thedata to every subscriber,
so email::send runs once per message:
Inspecting Queue Topics
A topic appears here once a function subscribes to it, so these commands inspect theemails topic
from above. (Publishing to a topic that nothing subscribes to does not register it, so there is
nothing to inspect.)
List every topic:
depth is messages waiting for the consumer, dlq_depth is
dead-lettered). A topic whose consumer keeps up sits at depth: 0:
Inspecting Dead Letter Queue Messages
A message reaches the dead-letter queue only once its subscribed function exhausts its retries, so the DLQ functions return empty until something fails.Forcing a message into the dead-letter queue
To see the DLQ populated, makeemail::send fail: change the handler to throw, and set
maxRetries: 0 in the trigger’s queue_config so the first failure dead-letters immediately
instead of after the default three attempts.
- Node / TypeScript
- Python
- Rust