Spring 我在哪里可以找到SqsListener
我们正在尝试使用接收来自AWS SQS的消息 我们希望使用注释接收消息。在春天,这是令人困惑的 下面,他们声明使用MessageMapping和QueueMessageHandler注释 注释驱动的侦听器端点是侦听的最简单方式 在SQS消息上。使用MessageMapping和 QueueMessageHandler将消息路由到带注释的方法 但在样本中,使用了@SQSListenerSpring 我在哪里可以找到SqsListener,spring,amazon-web-services,spring-cloud,amazon-sqs,Spring,Amazon Web Services,Spring Cloud,Amazon Sqs,我们正在尝试使用接收来自AWS SQS的消息 我们希望使用注释接收消息。在春天,这是令人困惑的 下面,他们声明使用MessageMapping和QueueMessageHandler注释 注释驱动的侦听器端点是侦听的最简单方式 在SQS消息上。使用MessageMapping和 QueueMessageHandler将消息路由到带注释的方法 但在样本中,使用了@SQSListener @SqsListener("queueName") public void queueListener(Pers
@SqsListener("queueName")
public void queueListener(Person person) {
// ...
}
我搜索了@SqsListener,发现它正在测试类中使用,比如。所以我们尝试导入,org.springframework.cloud.aws.messaging.listener.annotation.SqsListener
。遗憾的是,此注释类在最新版本中不可用
我使用的
org.springframework.cloud.aws.messaging.listener.annotation.SqsListener
是否正确?或者它还没有出现在发布的版本中?如果未发布,我可以使用@MessageMapping
接收来自SQS的消息吗?Spring Cloud AWS的1.0.4版本中似乎未包含该消息,但使用1.1.0.RC1时,我能够成功导入SqsListener
您需要添加:
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"
}
此外,还需要添加消息传递依赖项(我还包括了执行器):
注意,我还没有测试它是否可以实际使用SQS消息,但至少依赖关系正在解决。现在@SqsListener可用于1.1.0.RELEASE。我使用的是1.1.0.RELEASE,这就是我的依赖关系:
compile("org.springframework.boot:spring-boot-starter:1.3.5.RELEASE")
compile("org.springframework.cloud:spring-cloud-starter-aws-messaging:1.1.0.RELEASE")
我尝试了@SqsListener和@MessageMapping这两种注释,它们都可以正常工作。SqsListener是MessageMapping注释的专门化,它添加了一个附加属性,即删除策略
我猜文档必须更新,我也感到困惑 @Alian-你有什么线索吗?
compile("org.springframework.boot:spring-boot-starter:1.3.5.RELEASE")
compile("org.springframework.cloud:spring-cloud-starter-aws-messaging:1.1.0.RELEASE")