Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does @enablesns @enablesqs annotations do (spring cloud aws)?

I have been trying to find documentation of @enablesns @enablesqs annotations but can't find them.

They seem to be required for the sqs and sns integration to work. But I'd just like to have a better understanding, and be sure I'm not using them wrong.

Any description would be of great help.

like image 753
froi Avatar asked Sep 12 '18 07:09

froi


People also ask

What is spring cloud AWS messaging?

Spring Cloud AWS provides Amazon SQS and Amazon SNS integration that simplifies the publication and consumption of messages over SQS or SNS. While SQS fully relies on the messaging API introduced with Spring 4.0, SNS only partially implements it as the receiving part must be handled differently for push notifications.

What is @sqslistener?

Amazon Simple Queue Service (SQS) is a hosted message queuing service for distributing messages amongst machines. You can configure API Gateway to poll an Amazon SQS queue at a set rate. Any message found on the SQS queue in this interval can be sent to a policy for processing.

Can we use spring cloud in AWS?

Spring Cloud for AWS comes into play as an integrator of AWS services. In this tutorial, we'll develop a demo application that integrates with the core services Amazon Simple Storage Service (Amazon S3) and Amazon Simple Queue Service (Amazon SQS).


1 Answers

Looking at the source code for those two annotations:

@Import({SnsConfiguration.class, SnsWebConfiguration.class})
public @interface EnableSns

Where @Import does the following:

@interface Import: Indicates one or more @Configuration classes to import.

Long story short: Those annotations only combine multiple @Configuration classes into one single annotation.

E.g. @EnableSns does the same as adding @SnsConfiguration and @SnsWebConfiguration which provide you with AmazonSNS, RegionProvider and AWSCredentialsProvider beans.

like image 188
mana Avatar answered Sep 22 '22 08:09

mana