awspring SQS Configuration not working in Spring Boot Project

Viewed 20

We are attempting to move away from spring cloud aws to the new io.awspring.cloud project. The documentation states:

The AmazonSQSAsync client is automatically created and passed to the template’s constructor based on the provided credentials.

I am attempting to run this locally. In my pom.xml I have added the dependency:

<dependency>
   <groupId>io.awspring.cloud</groupId>
   <artifactId>spring-cloud-aws-messaging</artifactId>
   <version>${spring.cloud.aws}</version> 
</dependency>

And I removed the code to create an AmazonSQSAsync client. As per the documentation, I still define a QueueMessagingTemplate

import io.awspring.cloud.messaging.core.QueueMessagingTemplate;
import com.amazonaws.services.sqs.AmazonSQSAsync;

@Bean
@Qualifier
public QueueMessagingTemplate queueMessagingTemplateFifoSupport(AmazonSQSAsync amazonSQSAsync,
        ObjectMapper objectMapper) {
    MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
    converter.setSerializedPayloadClass(String.class);
    converter.setObjectMapper(objectMapper);

    QueueMessagingTemplate messagingTemplate = new QueueMessagingTemplate(amazonSQSAsync);
    messagingTemplate.setMessageConverter(converter);

    return messagingTemplate;
}

The package namespace was updated to use io.awspring. When running the app I get the error:

No qualifying bean of type 'com.amazonaws.services.sqs.AmazonSQSAsync' available

My belief is that Spring should supply this client automatically. Am I missing something?

In my application properties I have defined:

  • cloud.aws.credentials.access-key
  • cloud.aws.credentials.secret-key
  • cloud.aws.region.static
1 Answers

I was missing a dependency:

<dependency>
  <groupId>io.awspring.cloud</groupId>
  <artifactId>spring-cloud-aws-autoconfigure</artifactId>
  <version>${spring.cloud.aws}</version>
</dependency>

which is necessary for automatic creation of default clients.

On a side note- best to avoid using this for now as you will be locked in to v1 of the Java AWS SDK until you can upgrade io.awspring to a version compatible with both a newer version of spring boot and aws

Related