API Reference
Get a handle with queue(name) from @alienplatform/sdk (TypeScript) or alien_bindings::Bindings::from_env()?.queue(name).await? (Rust). Queue handles are bound to one queue by name — resolve the handle once, then call operations without repeating the queue name.
import { queue } from "@alienplatform/sdk"
const tasks = queue("tasks") // name matches the stack definitionsend
Sends a message to the queue.
await tasks.send({ type: "process-image", imageId: "123" }) // serialized as JSON
await tasks.sendText("ping") // raw text| Parameter | Type | Required | Description |
|---|---|---|---|
message | unknown (send) / string (sendText) | Yes | send serializes with JSON.stringify. Max 64 KiB after serialization. |
receive
Receives messages. Messages become invisible for 30 seconds (lease).
const messages = await tasks.receive(max)
// messages: QueueMessage[] — { payloadType, payload, receiptHandle, attempt }
for (const msg of messages) {
const payload = msg.payloadType === "json"
? JSON.parse(msg.payload)
: msg.payload
// ...
}| Parameter | Type | Required | Description |
|---|---|---|---|
max | number | Yes | Maximum messages to receive per call (max 10). |
ack / nack
ack acknowledges a message, permanently removing it. Idempotent. nack makes it immediately redeliverable.
await tasks.ack(msg.receiptHandle)
await tasks.nack(msg.receiptHandle)purge
Deletes every message in the queue.
await tasks.purge()Types
interface QueueMessage {
payloadType: "json" | "text" // Payload discriminant
payload: string // Serialized JSON when payloadType === "json", raw text when "text"
receiptHandle: string // Opaque handle for ack/nack
attempt: number // Delivery attempt, 1-based (1 = first delivery); > 1 means redelivery
}