option
HomeHome Skill Cloud Infrastructure aws-sdk-java-v2-messaging

aws-sdk-java-v2-messaging

giuseppe-trisciuoglio/developer-kit giuseppe-trisciuoglio/developer-kit

Provides AWS messaging patterns using AWS SDK for Java 2.x for SQS queues and SNS topics. Handles sending/receiving messages, FIFO queues, DLQ, subscriptions, and pub/sub patterns. Use when implementing messaging with SQS or SNS.

...Expand all
12
Updated time August 23, 2026

About aws-sdk-java-v2-messaging

aws-sdk-java-v2-messaging is a developer reference for implementing AWS messaging with the AWS SDK for Java 2.x, covering both Amazon SQS queues and Amazon SNS topics. It solves the problem of correctly wiring up producers, consumers, and pub/sub flows in Java services by consolidating idiomatic client setup and message-operation patterns with runnable code, so engineers building event-driven systems do not have to reassemble these from scattered docs.

The SKILL.md and its reference files demonstrate client configuration (SqsClient/SnsClient builders using DefaultCredentialsProvider and a region), SQS operations (create queue, send, receive with long polling, delete via receipt handle), FIFO queues with content-based deduplication and message group IDs, SNS operations (create topic, publish with subject and message attributes, FIFO publish), and SNS-to-SQS/email/Lambda subscriptions. It also shows Spring Boot integration with injected clients and configuration-driven topic ARNs, and points to advanced features such as dead letter queues, batch operations, visibility timeout, and using S3 for messages over 256KB. Bundled references cover detailed SQS and SNS operations, Spring Boot integration, and links to official AWS documentation and example repositories.

It targets Java backend developers building message buffering, pub/sub, and event-driven architectures on AWS, particularly those using Spring Boot. Credentials are handled through the SDK's standard DefaultCredentialsProvider rather than hardcoded secrets, and all shown operations are ordinary application-level messaging calls.

FAQ

What AWS services does this cover?

Amazon SQS (standard and FIFO queues, DLQ, long polling) and Amazon SNS (topics, publish, and subscriptions to SQS, email, and Lambda) using the AWS SDK for Java 2.x.

How are credentials handled?

Clients are built with DefaultCredentialsProvider and an explicit region, relying on the standard AWS credential chain rather than hardcoded keys in the skill.

Does it support Spring Boot?

Yes — it includes Spring Boot integration examples with injected SnsClient/ObjectMapper and topic ARNs supplied via @Value configuration, and a dedicated spring-boot-integration reference file.

Can it handle FIFO ordering and deduplication?

Yes. It shows FIFO queue and topic creation with content-based deduplication, plus message group IDs and deduplication IDs for ordered, exactly-once-style delivery.

What about large messages or failed messages?

The reference notes using S3 for messages larger than 256KB and configuring dead letter queues, visibility timeout, and batch operations for robust processing.

All Files

5 filesreferences/detailed-sns-operations.md5.1 KBViewreferences/aws-official-documentation.md5.2 KBViewreferences/detailed-sqs-operations.md6.0 KBViewreferences/spring-boot-integration.md7.7 KBViewSKILL.md7.2 KBView
View on GitHub

Overview

Provides patterns for SQS queues and SNS topics with AWS SDK for Java 2.x: client setup, queue management, message operations, subscriptions, and Spring Boot integration.

When to Use

  • Setting up SQS queues (standard or FIFO) for message buffering
  • Implementing pub/sub with SNS topics and subscriptions
  • Processing messages from SQS queues with long polling
  • Configuring dead letter queues (DLQ) for error handling
  • Integrating AWS messaging with Spring Boot applications
  • Building event-driven architectures with SQS/SNS

Examples

Quick Setup

Dependencies:

<dependency>    <groupId>software.amazon.awssdk</groupId>    <artifactId>sqs</artifactId></dependency><dependency>    <groupId>software.amazon.awssdk</groupId>    <artifactId>sns</artifactId></dependency>

Client Configuration:

SqsClient sqsClient = SqsClient.builder()    .region(Region.US_EAST_1)    .credentialsProvider(DefaultCredentialsProvider.create())    .build();SnsClient snsClient = SnsClient.builder()    .region(Region.US_EAST_1)    .build();

SQS Operations

Create and Send Message:

String queueUrl = sqsClient.createQueue(CreateQueueRequest.builder()    .queueName("my-queue")    .build()).queueUrl();String messageId = sqsClient.sendMessage(SendMessageRequest.builder()    .queueUrl(queueUrl)    .messageBody("Hello, SQS!")    .build()).messageId();

Receive and Delete Message:

ReceiveMessageResponse response = sqsClient.receiveMessage(ReceiveMessageRequest.builder()    .queueUrl(queueUrl)    .maxNumberOfMessages(10)    .waitTimeSeconds(20)    .build());response.messages().forEach(message -> {    processMessage(message.body());    sqsClient.deleteMessage(DeleteMessageRequest.builder()        .queueUrl(queueUrl)        .receiptHandle(message.receiptHandle())        .build());});

FIFO Queue:

Map<QueueAttributeName, String> attributes = Map.of(    QueueAttributeName.FIFO_QUEUE, "true",    QueueAttributeName.CONTENT_BASED_DEDUPLICATION, "true");String fifoQueueUrl = sqsClient.createQueue(CreateQueueRequest.builder()    .queueName("my-queue.fifo")    .attributes(attributes)    .build()).queueUrl();sqsClient.sendMessage(SendMessageRequest.builder()    .queueUrl(fifoQueueUrl)    .messageBody("Order #12345")    .messageGroupId("orders")    .messageDeduplicationId(UUID.randomUUID().toString())    .build());

SNS Operations

Create Topic and Publish:

String topicArn = snsClient.createTopic(CreateTopicRequest.builder()    .name("my-topic")    .build()).topicArn();snsClient.publish(PublishRequest.builder()    .topicArn(topicArn)    .subject("Test Notification")    .message("Hello, SNS!")    .build());

SNS to SQS Subscription:

String queueArn = sqsClient.getQueueAttributes(GetQueueAttributesRequest.builder()    .queueUrl(queueUrl)    .attributeNames(QueueAttributeName.QUEUE_ARN)    .build()).attributes().get(QueueAttributeName.QUEUE_ARN);snsClient.subscribe(SubscribeRequest.builder()    .protocol("sqs")    .endpoint(queueArn)    .topicArn(topicArn)    .build());

Spring Boot Integration

@Service@RequiredArgsConstructorpublic class OrderNotificationService {    private final SnsClient snsClient;    private final ObjectMapper objectMapper;    @Value("${aws.sns.order-topic-arn}")    private String orderTopicArn;    public void sendOrderNotification(Order order) throws JsonProcessingException {        snsClient.publish(PublishRequest.builder()            .topicArn(orderTopicArn)            .subject("New Order Received")            .message(objectMapper.writeValueAsString(order))            .messageAttributes(Map.of(                "orderType", MessageAttributeValue.builder()                    .dataType("String")                    .stringValue(order.getType())                    .build()))            .build());    }}

Instructions

Implement Message Processing (with Validation)

  1. Create queues/topics with appropriate configuration
  2. Send messages and validate messageId is returned
  3. Receive messages with long polling (waitTimeSeconds: 20)
  4. Process messages - validate payload before processing
  5. Delete messages only after successful processing - verify deletion response
  6. Check DLQ periodically for failed messages using redrivePolicy
  7. Verify delivery - monitor CloudWatch NumberOfMessagesSent metric

Validation Checklist:

// After sendif (messageId == null || messageId.isEmpty()) {    throw new MessagingException("Message send failed - no messageId returned");}// After receiveif (response.messages().isEmpty()) {    log.debug("No messages available - normal with long polling");}// After deleteif (!deleteResponse.sdkHttpResponse().isSuccessful()) {    throw new MessagingException("Message deletion failed");}

Setup Credentials

export AWS_ACCESS_KEY_ID=your-access-keyexport AWS_SECRET_ACCESS_KEY=your-secret-keyexport AWS_REGION=us-east-1

Monitor and Debug

  • CloudWatch metrics: ApproximateNumberOfMessages, NumberOfMessagesSent, NumberOfMessagesReceived
  • Enable SDK logging: software.amazon.awssdk at DEBUG level
  • Use X-Ray for distributed tracing

Best Practices

SQS:

  • Use long polling (20-40s) to reduce empty responses and costs
  • Always delete messages after successful processing
  • Implement idempotent processing for duplicate handling
  • Configure DLQ (redrivePolicy) for failed messages
  • Use FIFO queues when order matters (300 msg/sec limit)

SNS:

  • Use filter policies to reduce unnecessary deliveries
  • Keep messages under 256KB
  • Implement retry with exponential backoff
  • Monitor NumberOfNotificationFailed metric

General:

  • Use IAM roles over static credentials
  • Reuse clients (they are thread-safe)
  • Test with LocalStack or Testcontainers

Detailed References

  • references/detailed-sqs-operations.md
  • references/detailed-sns-operations.md
  • references/spring-boot-integration.md
  • references/aws-official-documentation.md

Constraints and Warnings

  • Message Size: Maximum 256KB for SQS and SNS
  • Visibility Timeout: Undeleted messages reappear after timeout - always delete after processing
  • Input Validation: Sanitize message body before processing - messages may contain untrusted payloads
  • FIFO Naming: Must end with .fifo suffix
  • FIFO Throughput: 300 msg/sec per queue (use partitioning for higher throughput)
  • Message Retention: SQS retains messages max 14 days
  • DLQ Required: Configure dead letter queue to prevent message loss
  • Region-Specific: SQS queues are region-specific; cross-region requires SNS

All Files

0 files

Install aws-sdk-java-v2-messaging

Download and extract the skill files to your .claude/skills/ directory.

Download ZIP

Clone the repository and copy the skill files to your project.

git clone https://github.com/giuseppe-trisciuoglio/developer-kit/blob/main/plugins/developer-kit-java/skills/aws-sdk-java-v2-messaging/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

Copy Copy
Quick Setup: Copy the skill folder to .claude/skills/Claude will automatically detect and use the skill

Related Skills

Cloudflare Manager
Updated time June 29, 2026
pinecone
Updated time June 29, 2026
azure-setup-guide
Updated time June 29, 2026
sentry-architecture-variants
Updated time June 29, 2026
OR