Documentation Index
Fetch the complete documentation index at: https://mintlify.com/anomalyco/sst/llms.txt
Use this file to discover all available pages before exploring further.
The Queue component lets you add a Cloudflare Queue to your app.
Constructor
const queue = new sst.cloudflare.Queue("MyQueue");
Properties
nodes
SDK
Send messages to the queue from your worker:
import { Resource } from "sst";
export default {
async fetch(request, env) {
await env.MyQueue.send({ message: "Hello" });
return new Response("Message sent");
}
};
Process messages from the queue:
export default {
async queue(batch) {
for (const message of batch.messages) {
console.log(message.body);
}
}
};
Examples
Create a queue
const queue = new sst.cloudflare.Queue("MyQueue");
Subscribe to a queue
const queue = new sst.cloudflare.Queue("MyQueue");
queue.subscribe("src/consumer.ts");
Link to a worker
const queue = new sst.cloudflare.Queue("MyQueue");
new sst.cloudflare.Worker("MyWorker", {
handler: "src/producer.ts",
link: [queue]
});