Skip to content

Instantly share code, notes, and snippets.

@pankajjs
Last active March 21, 2025 15:00
Show Gist options
  • Save pankajjs/c5235730f527e82e16d167da46771a83 to your computer and use it in GitHub Desktop.
Save pankajjs/c5235730f527e82e16d167da46771a83 to your computer and use it in GitHub Desktop.
The simplest way to integrate AWS SQS with spring boot service
# Add below dependecies in build.gradle
# Make sure to update the version
implementation 'io.awspring.cloud:spring-cloud-aws-starter-sqs:3.0.2'
implementation 'software.amazon.awssdk:sqs:2.20.82'
# Add these properties in application.properties file
# `${VAR_NAME}` coming from environment variables
aws.accessKey=${AWS_ACCESS_KEY_ID}
aws.secretKey=${AWS_SECRET_ACCESS_KEY}
aws.region=${AWS_REGION}
sqs.queueName=${AWS_SQS_NAME}
# Consumer
# Create a service class
@Service
public class SQSListenerService {
@SqsListener(value = "${sqs.queueName}")
public void onSubmissionMessage(String message) {
# process the message
System.out.println("Received message: " + message);
}
}
# Will add publisher soon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment