Skip to content
AWS docs0.4

Spring Boot SQS and SNS Workshop

Latest stable Based on AWS release 0.4.0

A runnable workshop grounded in the 0.4.0 release source.

Build a Spring Boot 4 messaging path with REST publishing, @SqsListener, typed conversion, manual acknowledgement, retry/backoff, interceptor events, SNS-to-SQS fanout, and DLQ redrive setup.

Use it before operating annotation-driven SQS listeners or when fanout, redrive, and duplicate-safe handler behavior need one executable reference.

This example is not published. Run ./gradlew :aws-spring-boot-sqs-examples:test. Applications import the central BOM, bluetape4k-aws-spring-boot, and the Java SDK SQS/SNS service modules.

The controller stays thin. SqsSnsExampleService owns queue URLs, policies, subscriptions, and redrive attributes. Listeners demonstrate plain messages, typed OrderPayload, manual ack, one in-process retry, and interceptor events.

  1. Create a queue and publish one plain message.
  2. Confirm the listener store and interceptor events.
  3. Send typed JSON and follow manual acknowledgement.
  4. Trigger retry-once behavior and inspect both attempts.
  5. Create SNS fanout, publish, then configure a source queue and DLQ.

SpringBootSqsExampleApplication starts the service. SqsSnsExampleController exposes queue creation, send/receive, fanout, SNS publish, DLQ setup, and listener inspection under /spring/sqs.

Make acknowledgement and business idempotency explicit before increasing concurrency. Prefer SQS redrive policy for durable poison-message handling; use in-process retry only for bounded transient failures.

Spring auto-configuration owns clients and listener containers. The service owns AWS resource relationships, while ReceivedOrderStore is only an in-memory teaching aid.

Configure SQS/SNS region and endpoint, listener queue names, poll limits, retry settings, and manual acknowledgement. Production also needs queue policy, redrive policy, visibility, retention, and shutdown budgets.

Duplicate delivery, invalid JSON, missing queue URLs, insufficient SNS-to-SQS policy, visibility expiry, poison messages, and listener shutdown during work are expected failure paths.

Track receive age, delivery count, retry, ack/nack, DLQ depth, and listener phase latency. Keep message bodies and queue URLs out of metric tags and close containers before clients.

SqsSnsExampleLocalStackTest supports Floci-first and explicit LocalStack fallback. It verifies queues, listeners, typed/manual ack, retry, events, fanout policy/subscription, publish, and DLQ redrive attributes.

Compare the Ktor SQS workshop for explicit runtime and observer hooks, then design durable idempotency and failure recovery around the business handler.

The in-memory stores do not survive restart. Emulator success does not prove IAM, production redrive timing, high concurrency, ordering, exactly-once processing, or cross-account fanout.

These diagrams are loaded directly from README assets published with the 0.4.0 release and pinned to its immutable commit. They describe this manual’s released structure and runtime flows, not later Snapshot changes. Select a preview to open the SVG at the same release commit.

aws spring boot sqs examples Architecture diagram

Section titled “aws spring boot sqs examples Architecture diagram”

aws spring boot sqs examples Architecture diagram

Release README: examples/aws-spring-boot-sqs-examples/README.md