I was trying to create a SQS queue listener in my spring boot app using the code below
AmazonSQSAsyncClient amazonSQSAsyncClient= new AmazonSQSAsyncClient(getProfileCredentialsProvider());
However AmazonSQSAsyncClient seems to be deprecated. Is there a different way of using builder to create this object?
How about this?
AmazonSQSAsyncClientBuilder.standard()
.withCredentials(getProfileCredentialsProvider())
.build();
That is really mentioned in the JavaDocs:
* @deprecated use {@link AmazonSQSAsyncClientBuilder#withCredentials(AWSCredentialsProvider)}
*/
@Deprecated
public AmazonSQSAsyncClient(AWSCredentialsProvider awsCredentialsProvider) {
For those of you looking for standard way of defining listeners.
Include spring-cloud-aws-messaging in your application, beware to not include the spring-cloud-aws-started-messaging .
Then you gain access to two ways of creating listeners:
@SqsListener(value = "logical queue name")
and programatically
@Autowired
private SimpleMessageListenerContainer simpleMessageListenerContainer;
...
simpleMessageListenerContainer.start("logical queue name");
spring will handle the creating of AmazonSQS client for you.
NOTE: for the @SqsListener
annotation you need @EnableSqs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.