Reputation: 5451
We are trying to use spring-cloud-aws to receive messages from AWS SQS
We would like to receive messages using annotation. In spring documentation, it is confusing.
Below, they stated to use MessageMapping and QueueMessageHandler annotation.
Annotation-driven listener endpoints are the easiest way for listening on SQS messages. Simply annotate methods with MessageMapping and the QueueMessageHandler will route the messages to the annotated methods.
But in the sample, @SQSListener is used.
@SqsListener("queueName")
public void queueListener(Person person) {
// ...
}
I searched for @SqsListener and found that it is being used in test classes like here . So we tried to import, org.springframework.cloud.aws.messaging.listener.annotation.SqsListener
. Unfortunately this annotation class is not available in latest release.
Is the org.springframework.cloud.aws.messaging.listener.annotation.SqsListener
that I am using is proper one? Or it is not yet present in released version? If not released can I use @MessageMapping
to receive messages from SQS?
Upvotes: 4
Views: 4474
Reputation: 31
I am using the 1.1.0.RELEASE, that's the dependencies I have:
compile("org.springframework.boot:spring-boot-starter:1.3.5.RELEASE")
compile("org.springframework.cloud:spring-cloud-starter-aws-messaging:1.1.0.RELEASE")
I tried both annotations @SqsListener and @MessageMapping both work fine. The SqsListener is a specialization of the MessageMapping annotation which is adding an additional property, the deletion policy.
I am guessing the documentation has to be updated, I got confused as well.
Upvotes: 3
Reputation: 2259
It appears to not be included in the 1.0.4 release of Spring Cloud AWS however I was able to successfully import SqsListener when using 1.1.0.RC1
You need to add:
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-aws:1.1.0.RC1'
mavenBom "org.springframework.boot:spring-boot-starter-parent:1.3.3.RELEASE"
}
Additionally the messaging dependency needs to be added (and I've got actuator included too):
dependencies {
compile("org.springframework.cloud:spring-cloud-starter-aws")
compile("org.springframework.cloud:spring-cloud-aws-messaging")
compile("org.springframework.boot:spring-boot-starter-actuator")
}
Note, I haven't tested it to see if it can actually consume a message of SQS but at least the dependency is resolving.
Upvotes: 3