Skip to main content
skill CX Codex

aws-sdk-java-v2-messaging — Claude Code skill: setup & patterns

Code patterns for AWS SQS and SNS using AWS SDK for Java 2.x. Helps configure clients, handle FIFO queues, set up DLQ, and integrate messaging into Spring Boot.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add giuseppe-trisciuoglio/developer-kit --skill aws-sdk-java-v2-messaging -a claude-code
Open on GitHub

What aws-sdk-java-v2-messaging does

The skill provides implementation patterns for messaging using AWS SDK for Java 2.x. It includes configuration templates for SqsClient and SnsClient, creation of standard and FIFO queues, and SQS subscriptions to SNS topics. For Spring Boot projects, it provides a sample service using ObjectMapper for payload serialisation.

The workflow covers receiving messages via long polling with waitTimeSeconds: 20, payload validation, and message removal via receiptHandle. Messages that are not deleted reappear once the visibility timeout expires. For error scenarios, the guide details dead letter queue routing using redrivePolicy.

Your project needs software.amazon.awssdk dependencies for sqs and sns, plus AWS credentials in environment variables. Note that payload size is capped at 256KB across both SQS and SNS.

What it helps with

  • configure SqsClient and SnsClient with explicit region and credentials
  • receive and delete messages from SQS using long polling
  • configure an SQS FIFO queue with deduplication and message group IDs
  • subscribe an SQS queue to an SNS topic
  • implement an SNS notification publisher in a Spring Boot service

Example prompts for the agent

  • Configure an SqsClient with AWS SDK Java 2.x and read messages using long polling
  • Show how to create an SQS FIFO queue with content-based deduplication
  • Write a Spring Boot service that publishes orders to an SNS topic

How to install aws-sdk-java-v2-messaging

1Skills CLI (Vercel)

npx skills add giuseppe-trisciuoglio/developer-kit --skill aws-sdk-java-v2-messaging -a claude-code

2Manually: put the files in place

~/.claude/skills/aws-sdk-java-v2-messaging/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/aws-sdk-java-v2-messaging/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about aws-sdk-java-v2-messaging

How do I install aws-sdk-java-v2-messaging in Claude Code?

Run npx skills add giuseppe-trisciuoglio/developer-kit --skill aws-sdk-java-v2-messaging -a claude-code in your terminal.

What does aws-sdk-java-v2-messaging provide?

It gives your AI agent verified patterns for AWS SDK for Java 2.x messaging, including SQS polling, FIFO queues, DLQ handling, and SNS pub/sub.

What are the main message size and throughput limits?

SQS and SNS limit message payloads to 256KB. For FIFO queues, the throughput constraint is 300 messages per second.

Source text

SKILL.md · MIT
---
name: aws-sdk-java-v2-messaging
description: 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.
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
---

# AWS SDK for Java 2.x - Messaging (SQS & SNS)

## 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:**
```xml
<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>sqs</artifactId>
</dependency>
<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>sns</artifactId>
</dependency>
```

**Client Configuration:**
```java
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:**
```java
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:**
```java
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:**
```java
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:**
```java
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:**
```java
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
```java
@Service
@RequiredArgsConstructor
public 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:**
```java
// After send
if (messageId == null || messageId.isEmpty()) {
    throw new MessagingException("Message send failed - no messageId returned");
}

// After receive
if (response.messages().isEmpty()) {
    log.debug("No messages available - normal with long polling");
}

// After delete
if (!deleteResponse.sdkHttpResponse().isSuccessful()) {
    throw new MessagingException("Message deletion failed");
}
```

### Setup Credentials
```bash
export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
export 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-sqs-operations.md)
- [references/detailed-sns-operations.md](references/detailed-sns-operations.md)
- [references/spring-boot-integration.md](references/spring-boot-integration.md)
- [references/aws-official-documentation.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

© giuseppe-trisciuoglio · MIT · giuseppe-trisciuoglio/developer-kit

Similar skills

Everything for Cloud: AWS, Azure, GCP →

From the same set93

chunking-strategy Configures document chunking workflows and overlap for RAG pipelines and vector search. It validates semantic coherence and tunes retrieval precision. CX Codex +1 3,800installs aws-sdk-java-v2-rds Guides AI agents in managing Amazon RDS databases via the AWS SDK for Java 2.x. Useful for provisioning instances, snapshots, and parameter groups. CX Codex +1 3,700installs aws-sdk-java-v2-kms This skill provides AWS KMS patterns for AWS SDK for Java 2.x, covering keys, encryption, data keys, signatures, and Spring Boot integration. CX Codex +1 3,700installs aws-sdk-java-v2-secrets-manager A skill for pulling AWS Secrets Manager values into Java services: retrieval, caching, rotation-aware access and Spring Boot wiring. CX Codex +1 3,700installs aws-sdk-java-v2-bedrock A skill that shows your agent how to call Amazon Bedrock models from AWS SDK for Java 2.x: text, images, embeddings and streaming. CX Codex +1 3,700installs nextjs-deployment Provides production deployment patterns for Next.js. Sets up multi-stage Dockerfiles, GitHub Actions workflows, health checks, and OpenTelemetry instrumentation. CX Codex +1 3,700installs aws-sdk-java-v2-lambda A skill that feeds your agent AWS Lambda patterns built on AWS SDK for Java 2.x. Useful when your Java service calls or deploys Lambda functions. CX Codex +1 3,700installs aws-rds-spring-boot-integration A skill that walks through wiring AWS RDS into Spring Boot: HikariCP pooling, SSL, IAM auth, Secrets Manager. CX Codex +1 3,700installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor