Skip to content

Queues

Send work to a queue from your app and process it in the background, with retries and a dead-letter queue.

Applies to EngineCloud
View as Markdown
On this page
  1. How it behaves
  2. Limits from AWS

A queue holds messages until a consumer processes them. Use it for anything that should not make a visitor wait: sending e-mails, resizing images, printing kitchen tickets, importing a file.

sypnia.toml
[run.apps.laespiga.queues.kitchen]
consumer = "workers/kitchen.ts"
batch = 10
retries = 5          # attempts in all, 1 to 20 (5 when left out)
concurrency = 4
TypeScript
// in your app
import { queue } from '@sypnia/run/queue';
await queue('kitchen').send({ order: 1042 }, { delaySeconds: 0, dedupeId: 'order-1042' });

// workers/kitchen.ts
import { consumer } from '@sypnia/run/queue';
export default consumer<{ order: number }>(async (messages) => {
  for (const m of messages) await printTicket(m.body.order);
});

How it behaves

  • Each queue is an Amazon SQS queue of the app’s environment, with a dead-letter queue next to it.
  • A batch that throws is tried again with growing waits: 5 attempts in all by default, or what retries says (1 to 20). After the last attempt its messages move to the dead-letter queue, where run queues dlq kitchen lists them and --replay sends them back.
  • Delivery is at least once: process messages so that receiving one twice does no harm (dedupeId drops duplicates sent within five minutes).
  • delaySeconds holds a message up to 15 minutes before it can be received.
  • Consumers scale with the queue’s length up to concurrency.

Limits from AWS

A message body is up to 256 KB; put bigger payloads in Sypnia Files and send the path.

  1. How it behaves
  2. Limits from AWS

    Search pages, sections and terms