Queues
DocsQueues decouple the route that publishes work from the worker that processes it. This demo creates a queue, publishes sample messages, shows ack/nack behavior, and exposes the dead letter queue after failures. Use queues when work can run after the request returns or needs retries. Use schedules when time, not an incoming request, starts the work.
Setup
Event Log
Click "Setup Queue" to begin.
Tip: Publish a message, then receive and nack it 2 times to move it to the Dead Letter Queue. Replay returns it to the main queue.
Reference Code
import { QueueClient } from "@agentuity/queue";
const queues = new QueueClient();
const queueName = "orders-" + crypto.randomUUID();
let published: Awaited<ReturnType<typeof queues.publish>> | undefined;
let created = false;
try {
await queues.createQueue(queueName, {
queueType: "worker",
settings: {
defaultMaxRetries: 3,
defaultVisibilityTimeoutSeconds: 30,
},
});
created = true;
published = await queues.publish(queueName, {
task: "process-order",
orderId: "order-123",
priority: "high",
}, {
sync: true,
idempotencyKey: "order-123-v1",
metadata: { source: "checkout" },
});
await queues.publish(queueName, {
task: "send-receipt",
orderId: "order-123",
});
} finally {
if (created) await queues.deleteQueue(queueName);
}
// Queue workers receive, ack, nack, and dead-letter messages from the
// Agentuity runtime route, not from the standalone QueueClient.
export { published };Ready
Output will appear here...