Skip to content

AWS SQS – MessageConsumer stops to receive messages after a while

My application registers a listeners to a SQS queue (queue itself is populated by a SNS topic). When I start the application, message consumer is working as expected but after a while it stops to receive any messages. Can it be that consumer is shutting down after a while?

Suggestions or comments would be much appreciated.


public SQSConnection amazonSQSConnection(
      @Value("${aws.access.key}") String accessKey,
      @Value("${aws.secret.key}") String secretKey) throws JMSException {

BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonSQSClientBuilder client = AmazonSQSClientBuilder
        .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials));
SQSConnectionFactory connectionFactory = new SQSConnectionFactory(new ProviderConfiguration(), client);

return connectionFactory.createConnection();


 public MessageConsumer workOrderChangeConsumer(
      SQSConnection connection,
      WorkOrderKittingService workOrderKittingService,
      AuthenticationProvider authProvider,
      @Value("${}") String appUserName,
      @Value("${aws.sqs.workorder.change.queue}") String woChangeQueue) throws JMSException {

Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
Queue queue = session.createQueue(woChangeQueue);

WorkOrderChangeIngestor workOrderChangeIngestor = new WorkOrderChangeIngestor(

MessageConsumer consumer = session.createConsumer(queue);

return consumer;


You’re trying to manage the connection lifecycle by yourself.

I recommend you to let spring manage that for you, by using spring-cloud-aws

You can create a listener through annotations:

public class MyMessageHandler {

    void handle(String message) {
        throw new MyException("something went wrong");

    void handleException(MyException e) {