Search code examples
javaspringspring-cloud-aws

How To Override Default SQS Configurations For Spring Cloud AWS Messaging


Specifically looking to override the default AmazonSQSAsync client in order to ensure that the client is compatible with FIFO queues as mentioned in the version 2.4.2 documentation here . Defining a bean in my application in a @Configuration class similar to the documentation (as shown below) still results in the warning AmazonSQSBufferedAsyncClient that Spring Cloud AWS uses by default to communicate with SQS is not compatible with FIFO queues. Consider registering non-buffered AmazonSQSAsyncClient bean. Although, requests do seem to work I have not yet been able to determine if the correct AmazonSQSAsync client is being used. I'm looking for either a way to adjust my configuration that removes this warning (because my AmazonSQSAsync bean is being used) or way to confirm that the message is actually a red herring. The dependency I'm using is spring-cloud-aws-messaging version 2.4.2

@Configuration
public class SQSConfig {

    @Bean
    public AmazonSQSAsync amazonSQS(@Value("${aws.region}") String awsRegion) {
        return AmazonSQSAsyncClientBuilder.standard()
                .withCredentials(DefaultAWSCredentialsProviderChain.getInstance())
                .withRegion(awsRegion)
                .build();
    }
}


Solution

  • Looks like it was an error with configuration. I had mistakenly left the xml configuration <aws-messaging:annotation-driven-queue-listener /> active which was the source of the erroneous SQS client. Removing that xml configuration and including an override of the amazonSQS bean (bean name must match exactly) with an instance of AmazonSQSAsync solved the issue.