Overview
Asynchronous message passing between components across any cloud.
Queue provides at-least-once message delivery between producers and consumers. Send JSON or text messages, receive them in batches, and acknowledge when processing is complete. Unacknowledged messages are automatically re-delivered.
Platform Mapping
| Platform | Backing Service | Provisioned by |
|---|---|---|
| AWS | Amazon SQS (Standard) | Alien |
| GCP | Google Cloud Pub/Sub | Alien |
| Azure | Azure Service Bus | Alien |
| Local | sled (embedded database) | Alien |
When to Use
Use Queue for decoupling producers from consumers — task queues, event pipelines, background job processing, webhook relay.
Don't use Queue for request-response patterns (use Function invocation) or for ordered event streams (Queue does not guarantee ordering).
Stack Definition
Declare a Queue resource in your alien.ts:
const tasks = new alien.Queue("tasks").build()| Parameter | Type | Description |
|---|---|---|
id | string | Resource identifier. [A-Za-z0-9-_], max 64 characters. |
Queue has no additional configuration options. The backing service (SQS, Pub/Sub, Service Bus) is determined by the deployment platform.
Quick Start
import { queue } from "@alienplatform/sdk"
const tasks = await queue("tasks")
await tasks.send("tasks", { type: "process-image", imageId: "123" })
const messages = await tasks.receive("tasks", 10)
for (const msg of messages) {
await processTask(msg.payload)
await tasks.ack("tasks", msg.receiptHandle)
}let q = ctx.bindings().load_queue("tasks").await?;
q.send("tasks", MessagePayload::Json(json!({"type": "process-image"}))).await?;
let messages = q.receive("tasks", 10).await?;
for msg in messages {
// process...
q.ack("tasks", &msg.receipt_handle).await?;
}Triggers
Queues can automatically trigger functions — one message per invocation:
// alien.ts
const worker = new alien.Function("worker")
.trigger(tasks)
.build()// worker code
import { onQueueMessage } from "@alienplatform/sdk"
onQueueMessage("tasks", async (message) => {
await processTask(message.payload)
// auto-acknowledged on success
})See Behavior & Limits for trigger support per platform.