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.
Learning goal
Section titled “Learning goal”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.
When to use this workshop
Section titled “When to use this workshop”Use it before operating annotation-driven SQS listeners or when fanout, redrive, and duplicate-safe handler behavior need one executable reference.
Project coordinates
Section titled “Project coordinates”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.
Concepts to learn
Section titled “Concepts to learn”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.
Staged walkthrough
Section titled “Staged walkthrough”- Create a queue and publish one plain message.
- Confirm the listener store and interceptor events.
- Send typed JSON and follow manual acknowledgement.
- Trigger retry-once behavior and inspect both attempts.
- Create SNS fanout, publish, then configure a source queue and DLQ.
Entry points and expected behavior
Section titled “Entry points and expected behavior”SpringBootSqsExampleApplication starts the service. SqsSnsExampleController exposes queue creation, send/receive, fanout, SNS publish, DLQ setup, and listener inspection under /spring/sqs.
Recommended exercise order
Section titled “Recommended exercise order”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.
Integration boundary
Section titled “Integration boundary”Spring auto-configuration owns clients and listener containers. The service owns AWS resource relationships, while ReceivedOrderStore is only an in-memory teaching aid.
Configuration checkpoints
Section titled “Configuration checkpoints”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.
Failure modes
Section titled “Failure modes”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.
Operations
Section titled “Operations”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.
Testing the boundary
Section titled “Testing the boundary”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.
Next learning path
Section titled “Next learning path”Compare the Ktor SQS workshop for explicit runtime and observer hooks, then design durable idempotency and failure recovery around the business handler.
Limitations
Section titled “Limitations”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.
Release diagrams
Section titled “Release diagrams”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”Release README: examples/aws-spring-boot-sqs-examples/README.md
