Skip to content

Conversation

khc41
Copy link

@khc41 khc41 commented Aug 18, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Added automatic SQS batching support using AWS SDK's SqsAsyncBatchManager.

This feature enables automatic request batching for SQS operations to improve performance and reduce AWS API calls. When enabled, Spring Cloud AWS automatically wraps the SqsAsyncClient with a BatchingSqsClientAdapter that uses SqsAsyncBatchManager internally.

Key Features:

  • Automatic batching for sendMessage, receiveMessage, deleteMessage, and changeMessageVisibility operations
  • Configurable batch size, frequency, and timeout settings
  • Full Spring Boot auto-configuration support
  • Transparent integration with existing SqsTemplate and @SqsListener code
  • Smart attribute handling to avoid AWS SDK batching bypass

Configuration Example:

spring.cloud.aws.sqs.batch.enabled=true
spring.cloud.aws.sqs.batch.max-number-of-messages=10
spring.cloud.aws.sqs.batch.send-batch-frequency=PT0.2S

Important: Operations are processed asynchronously. Applications should handle returned CompletableFuture objects to detect actual transmission errors.

💡 Motivation and Context

AWS SDK 2.28.0+ introduced automatic request batching capabilities that can significantly improve SQS performance and reduce costs by combining multiple API calls into fewer requests.

Previously, users had to manually implement batching logic or use explicit batch operations. This change enables declarative batching at the configuration level, providing:

  • Improved performance: Reduced network overhead and latency
  • Cost reduction: Fewer API calls mean lower AWS charges
  • Better resource utilization: More efficient use of network and AWS resources
  • Zero code changes: Existing applications work without modification

This addresses the community request for supporting AWS SDK's new automatic batching feature in Spring Cloud AWS.

💚 How did you test it?

Unit Tests:

  • BatchingSqsClientAdapterTests: Comprehensive testing of all adapter methods with mock SqsAsyncBatchManager
  • Verified proper delegation of all SQS operations and error handling

Integration Tests:

  • BatchingSqsClientAdapterIntegrationTests: Real SQS environment testing with LocalStack
  • Verified actual message sending, receiving, deleting, and visibility changes
  • Tested batching efficiency with multiple concurrent operations

Auto-Configuration Tests:

  • Extended SqsAutoConfigurationTest with comprehensive batch configuration testing
  • Verified conditional bean creation based on spring.cloud.aws.sqs.batch.enabled
  • Tested all configuration properties mapping and validation

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated reference documentation to reflect the change
  • All tests passing
  • No breaking changes

🔮 Next steps

This implementation provides full support for AWS SDK's automatic batching capabilities. Future enhancements could include:

  • Metrics and monitoring integration for batch performance
  • Advanced batching strategies based on message types
  • Enhanced observability for batching operations

Related AWS SDK Documentation: Use automatic request batching for Amazon SQS

Resolves #1355

@github-actions github-actions bot added component: sqs SQS integration related issue type: documentation Documentation or Samples related issue labels Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: sqs SQS integration related issue type: documentation Documentation or Samples related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatic requests batching for SQS messages
1 participant