Skip to main content

Path

The way of an SQS message through a RustStream service: the receive, the delivery, the handler, the reply and the delete, one at a time or in batches.

The path of a message, one at a time with its reply on the left and in batches on the right, from the receive to the deleteOne at a timeBatchesReceiveMessage10, wait 20 sChannelholds one batchSqsMessagehanded over one by oneHandlerdecodes and runsReply: SendMessageor an SNS PublishackDeleteMessageReceiveMessagesize n, up to 10Channelholds one batchVec<SqsMessage>never emptyBatch handlerone call per batchEach elementits own DeleteMessage
The diagram as text
  1. One at a time: ReceiveMessage 10, wait 20 s; Channel holds one batch; SqsMessage handed over one by one; Handler decodes and runs; Reply: SendMessage or an SNS Publish; ack DeleteMessage
  2. Batches: ReceiveMessage size n, up to 10; Channel holds one batch; Vec<SqsMessage> never empty; Batch handler one call per batch; Each element its own DeleteMessage
  3. ReceiveMessage 10, wait 20 s → Channel holds one batch: a batch
  4. Channel holds one batch → SqsMessage handed over one by one
  5. SqsMessage handed over one by one → Handler decodes and runs
  6. Handler decodes and runs → Reply: SendMessage or an SNS Publish
  7. Reply: SendMessage or an SNS Publish → ack DeleteMessage
  8. ReceiveMessage size n, up to 10 → Channel holds one batch
  9. Channel holds one batch → Vec<SqsMessage> never empty
  10. Vec<SqsMessage> never empty → Batch handler one call per batch
  11. Batch handler one call per batch → Each element its own DeleteMessage

The pump asks for ten messages per receive, with every message attribute and system attribute, and waits up to 20 seconds. It names a visibility timeout only when the descriptor names one. A long poll that ends empty yields nothing, so a batch is never empty. The channel holds one batch, so the pump is at most one receive ahead of the handlers.

Each message becomes an SqsMessage. The body is copied out of the SDK's answer, and the message attributes become headers, together with the message group and the receive count. The delivery also starts its visibility extender. These are a few allocations per message, and Benchmarks publishes what a message costs.

A subscription that handles one message at a time takes the batch apart and hands its messages over in order. A batch subscription asks for its own size, capped at ten, and its handler takes the whole batch in one call. Every message of a batch is still deleted with a call of its own.

A reply is encoded into a buffer the dispatch loop reuses. The SqsPublisher takes that buffer as the body of one SendMessage, or the SnsPublisher as the body of one Publish. The queue URL or topic ARN is resolved once and cached.

The delivery settles after the reply. Each settlement goes through the SDK clients of the runtime that settles it, and what each outcome does is on Settlement.