Install this skill
npx skills add giuseppe-trisciuoglio/developer-kitWorks across Claude Code, Cursor, Codex, Copilot & Antigravity
The aws-sdk-java-v2-messaging skill provides a functional interface for integrating Java applications with Amazon Simple Queue Service and Simple Notification Service. It enables the programmatic construction, configuration, and management of messaging infrastructure within AWS. Developers can perform standard operations including queue creation, message dispatch, polling, and deletion while handling the distinct requirements of FIFO queues and SNS topic subscriptions. The skill focuses on using the non-blocking features and improved modularity of the AWS SDK for Java 2.x, ensuring type safety and efficient resource handling. It simplifies the implementation of asynchronous communication, event-driven architectures, and system decoupling, bridging the gap between application logic and managed cloud messaging services through clean, client-based interactions.
When to Use This Skill
- •Building microservices that communicate asynchronously to improve system reliability
- •Implementing load-leveling patterns to buffer traffic spikes in high-demand backends
- •Fan-out event notifications where one system update triggers multiple downstream tasks
- •Ensuring strictly ordered processing of jobs via FIFO queues
How to Invoke This Skill
Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:
- “how to send a message to SQS using Java SDK v2
- “set up an SNS topic and subscribe an SQS queue programmatically
- “implement SQS FIFO queue with deduplication in Java
- “delete messages from SQS after processing in Spring Boot
- “receive and process batch messages from an AWS queue
Pro Tips
- 💡Always implement idempotent message processing for SQS consumers to prevent duplicate message side effects, especially during retries or scaling events.
- 💡Utilize LocalStack or Testcontainers extensively for robust local development and testing of SQS/SNS integrations, minimizing cloud costs and accelerating feedback cycles.
- 💡For high-throughput or cost-sensitive scenarios, leverage batching operations when sending or receiving messages from SQS/SNS to optimize API calls and reduce latency.
What this skill does
- •Programmatic creation and configuration of standard and FIFO SQS queues
- •Subscription management linking SNS topics to SQS endpoints or other protocols
- •Long-polling message retrieval with configurable wait times and batch processing
- •Decoupled event publishing using SNS topics for fan-out architectures
- •Integration with Spring Boot for dependency injection of messaging clients
When not to use it
- ✕When requiring real-time, low-latency streaming data processing where Kinesis is more appropriate
- ✕For simple inter-thread communication within a single JVM application
Example workflow
- Initialize the SqsClient and SnsClient using the builder pattern with a target region.
- Provision a message queue or SNS topic using the appropriate CreateRequest objects.
- Map application events to messages and dispatch them using the client's publish or send methods.
- Implement a polling loop that retrieves messages with long polling enabled to optimize API costs.
- Process the message payload and issue a delete call to the queue once the task is successfully completed.
Prerequisites
- –Active AWS account with IAM permissions for SQS and SNS
- –Maven or Gradle project configured with AWS SDK v2 dependencies
- –Configured AWS credentials via environment variables or a shared credentials file
Pitfalls & limitations
- !Forgetting to delete messages after processing, which leads to them reappearing in the queue after the visibility timeout.
- !Exceeding the 256KB payload limit for standard SQS messages.
- !Failing to account for the additional cost and throughput limitations of FIFO queues.
FAQ
How it compares
Unlike manual REST API calls, this skill handles request signing, marshalling, and error retries natively, reducing boilerplate and potential security misconfigurations.
📄 Full skill instructions — original source: giuseppe-trisciuoglio/developer-kit
## Overview
Provide comprehensive AWS messaging patterns using AWS SDK for Java 2.x for both SQS and SNS services. Include client setup, queue management, message operations, subscription management, and Spring Boot integration patterns.
## When to Use
Use this skill when working with:
- Amazon SQS queues for message queuing
- SNS topics for event publishing and notification
- FIFO queues and standard queues
- Dead Letter Queues (DLQ) for message handling
- SNS subscriptions with email, SMS, SQS, Lambda endpoints
- Pub/sub messaging patterns and event-driven architectures
- Spring Boot integration with AWS messaging services
- Testing strategies using LocalStack or Testcontainers
## Quick Start
### Dependencies
<!-- SQS -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sqs</artifactId>
</dependency>
<!-- SNS -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sns</artifactId>
</dependency>### Basic Client Setup
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sqs.SqsClient;
import software.amazon.awssdk.services.sns.SnsClient;
SqsClient sqsClient = SqsClient.builder()
.region(Region.US_EAST_1)
.build();
SnsClient snsClient = SnsClient.builder()
.region(Region.US_EAST_1)
.build();## Examples
### Basic SQS Operations
#### Create and Send Message
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sqs.SqsClient;
import software.amazon.awssdk.services.sqs.model.*;
// Setup SQS client
SqsClient sqsClient = SqsClient.builder()
.region(Region.US_EAST_1)
.build();
// Create queue
String queueUrl = sqsClient.createQueue(CreateQueueRequest.builder()
.queueName("my-queue")
.build()).queueUrl();
// Send message
String messageId = sqsClient.sendMessage(SendMessageRequest.builder()
.queueUrl(queueUrl)
.messageBody("Hello, SQS!")
.build()).messageId();#### Receive and Delete Message
// Receive messages with long polling
ReceiveMessageResponse response = sqsClient.receiveMessage(ReceiveMessageRequest.builder()
.queueUrl(queueUrl)
.maxNumberOfMessages(10)
.waitTimeSeconds(20)
.build());
// Process and delete messages
response.messages().forEach(message -> {
System.out.println("Received: " + message.body());
sqsClient.deleteMessage(DeleteMessageRequest.builder()
.queueUrl(queueUrl)
.receiptHandle(message.receiptHandle())
.build());
});### Basic SNS Operations
#### Create Topic and Publish
import software.amazon.awssdk.services.sns.SnsClient;
import software.amazon.awssdk.services.sns.model.*;
// Setup SNS client
SnsClient snsClient = SnsClient.builder()
.region(Region.US_EAST_1)
.build();
// Create topic
String topicArn = snsClient.createTopic(CreateTopicRequest.builder()
.name("my-topic")
.build()).topicArn();
// Publish message
String messageId = snsClient.publish(PublishRequest.builder()
.topicArn(topicArn)
.subject("Test Notification")
.message("Hello, SNS!")
.build()).messageId();### Advanced Examples
#### FIFO Queue Pattern
// Create 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();
// Send FIFO message with group ID
String fifoMessageId = sqsClient.sendMessage(SendMessageRequest.builder()
.queueUrl(fifoQueueUrl)
.messageBody("Order #12345")
.messageGroupId("orders")
.messageDeduplicationId(UUID.randomUUID().toString())
.build()).messageId();#### SNS to SQS Subscription
// Create SQS queue for subscription
String subscriptionQueueUrl = sqsClient.createQueue(CreateQueueRequest.builder()
.queueName("notification-subscriber")
.build()).queueUrl();
// Get queue ARN
String queueArn = sqsClient.getQueueAttributes(GetQueueAttributesRequest.builder()
.queueUrl(subscriptionQueueUrl)
.attributeNames(QueueAttributeName.QUEUE_ARN)
.build()).attributes().get(QueueAttributeName.QUEUE_ARN);
// Subscribe SQS to SNS
String subscriptionArn = snsClient.subscribe(SubscribeRequest.builder()
.protocol("sqs")
.endpoint(queueArn)
.topicArn(topicArn)
.build()).subscriptionArn();### Spring Boot Integration Example
@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) {
try {
String jsonMessage = objectMapper.writeValueAsString(order);
snsClient.publish(PublishRequest.builder()
.topicArn(orderTopicArn)
.subject("New Order Received")
.message(jsonMessage)
.messageAttributes(Map.of(
"orderType", MessageAttributeValue.builder()
.dataType("String")
.stringValue(order.getType())
.build()))
.build());
} catch (Exception e) {
throw new RuntimeException("Failed to send order notification", e);
}
}
}## Best Practices
### SQS Best Practices
- **Use long polling**: Set
waitTimeSeconds (20-40 seconds) to reduce empty responses- **Batch operations**: Use
sendMessageBatch for multiple messages to reduce API calls- **Visibility timeout**: Set appropriately based on message processing time (default 30 seconds)
- **Delete messages**: Always delete messages after successful processing
- **Handle duplicates**: Implement idempotent processing for retries
- **Implement DLQ**: Route failed messages to dead letter queues for analysis
- **Monitor queue depth**: Use CloudWatch alarms for high queue backlog
- **Use FIFO queues**: When message order and deduplication are critical
### SNS Best Practices
- **Use filter policies**: Reduce noise by filtering messages at the source
- **Message attributes**: Add metadata for subscription routing decisions
- **Retry logic**: Handle transient failures with exponential backoff
- **Monitor failed deliveries**: Set up CloudWatch alarms for failed notifications
- **Security**: Use IAM policies for access control and data encryption
- **FIFO topics**: Use when order and deduplication are critical
- **Avoid large payloads**: Keep messages under 256KB for optimal performance
### General Guidelines
- **Region consistency**: Use the same region for all AWS resources
- **Resource naming**: Use consistent naming conventions for queues and topics
- **Error handling**: Implement proper exception handling and logging
- **Testing**: Use LocalStack for local development and testing
- **Documentation**: Document subscription endpoints and message formats
## Instructions
### Setup AWS Credentials
Configure AWS credentials using environment variables, AWS CLI, or IAM roles:
export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
export AWS_REGION=us-east-1### Configure Clients
// Basic client configuration
SqsClient sqsClient = SqsClient.builder()
.region(Region.US_EAST_1)
.build();
// Advanced client with custom configuration
SnsClient snsClient = SnsClient.builder()
.region(Region.US_EAST_1)
.credentialsProvider(DefaultCredentialsProvider.create())
.httpClient(UrlConnectionHttpClient.create())
.build();### Implement Message Processing
1. **Connect** to SQS/SNS using the AWS SDK clients
2. **Create** queues and topics as needed
3. **Send/receive** messages with appropriate timeout settings
4. **Process** messages in batches for efficiency
5. **Delete** messages after successful processing
6. **Handle** failures with proper error handling and retries
### Integrate with Spring Boot
1. **Configure** beans for
SqsClient and SnsClient in @Configuration classes2. **Use**
@Value to inject queue URLs and topic ARNs from properties3. **Create** service classes with business logic for messaging operations
4. **Implement** error handling with
@Retryable or custom retry logic5. **Test** integration using Testcontainers or LocalStack
### Monitor and Debug
- Use AWS CloudWatch for monitoring queue depth and message metrics
- Enable AWS SDK logging for debugging client operations
- Implement proper logging for message processing activities
- Use AWS X-Ray for distributed tracing in production environments
## Troubleshooting
### Common Issues
- **Queue does not exist**: Verify queue URL and permissions
- **Message not received**: Check visibility timeout and consumer logic
- **Permission denied**: Verify IAM policies and credentials
- **Connection timeout**: Check network connectivity and region configuration
- **Rate limiting**: Implement retry logic with exponential backoff
### Performance Optimization
- Use long polling to reduce empty responses
- Batch message operations to minimize API calls
- Adjust visibility timeout based on processing time
- Implement connection pooling and reuse clients
- Use appropriate message sizes to avoid fragmentation
## Detailed References
For comprehensive API documentation and advanced patterns, see:
- [@references/detailed-sqs-operations] - Complete SQS operations reference
- [@references/detailed-sns-operations] - Complete SNS operations reference
- [@references/spring-boot-integration] - Spring Boot integration patterns
- [@references/aws-official-documentation] - Official AWS documentation and best practices
How to Use This Skill Unit
Option A: Project-Specific (Recommended)
- Click "Download" above
- In your project, create the directory:
.agent/skills/aws-sdk-java-v2-messaging/ - Save the file as
SKILL.md - The agent will automatically discover the skill based on its description.
Option B: Global Installation (All Agents)
Save the file to these locations to make it available across all projects:
- Claude Code:
~/.claude/skills/giuseppe-trisciuoglio/developer-kit/aws-sdk-java-v2-messaging/SKILL.md - Cursor:
~/.cursor/skills/giuseppe-trisciuoglio/developer-kit/aws-sdk-java-v2-messaging/SKILL.md - Antigravity:
~/.gemini/antigravity/skills/giuseppe-trisciuoglio/developer-kit/aws-sdk-java-v2-messaging/SKILL.md
🚀 Install with CLI:npx skills add giuseppe-trisciuoglio/developer-kit