Skip to content

QueueSink

Source: src/AWS/SQS/QueueSink.ts

A batching sink over SQS SendMessageBatch (10 entries / 256 KiB per call). Per-entry failures with SenderFault: false (throttling, internal errors) are retried on a bounded schedule; SenderFault: true failures are permanent and dropped. Exhausting retries fails the sink with a typed BatchRetryExhaustedError carrying the stranded entries.

The binding grants the host function sqs:SendMessage and sqs:SendMessageBatch on the queue. Provide the QueueSinkHttp layer (which itself needs SendMessageBatchHttp) on the Function to implement the binding.

Run a Stream into a Queue

// init (provide SQS.QueueSinkHttp + SQS.SendMessageBatchHttp on the Function)
const sink = yield* SQS.QueueSink(queue);
// runtime: batching, size limits, and transient-failure retry are handled
// by the sink — each element is a SendMessageBatchRequestEntry minus `Id`.
yield* Stream.fromIterable(messages).pipe(
Stream.map((message) => ({ MessageBody: message })),
Stream.run(sink),
);

Forward Event-Source Records into a Result Queue

const sink = yield* SQS.QueueSink(resultQueue);
yield* SQS.consumeQueueMessages(sourceQueue, (records) =>
records.pipe(
Stream.map((record) => ({ MessageBody: record.body })),
Stream.run(sink),
Effect.orDie,
),
);