28

我正在尝试让 Spring Cloud 使用自动配置来处理消息传递。

我的属性文件包含:

cloud.aws.credentials.accessKey=xxxxxxxxxx
cloud.aws.credentials.secretKey=xxxxxxxxxx

cloud.aws.region.static=us-west-2

我的配置类如下:

@EnableSqs
@ComponentScan
@EnableAutoConfiguration
public class Application {


public static void main(String[] args) throws Exception {
    SpringApplication.run(Application.class, args);
  }
}

我的听众课:

@RestController
public class OrderListener {

    @MessageMapping("orderQueue")
    public void orderListener(Order order){

        System.out.println("Order Name " + order.getName());
        System.out.println("Order Url" + order.getUrl());

    }
}

但是,当我运行它时。我收到以下错误:

org.springframework.context.ApplicationContextException: Failed to start bean        'simpleMessageListenerContainer'; nested exception is     org.springframework.messaging.core.DestinationResolutionException: The specified queue does not exist for this wsdl version. (Service: AmazonSQS; Status Code: 400; Error Code: AWS.SimpleQueueService.NonExistentQueue; Request ID: cc8cb199-be88-5993-bd58-fca3c9f17110); nested exception is com.amazonaws.services.sqs.model.QueueDoesNotExistException: The specified queue does not exist for this wsdl version. (Service: AmazonSQS; Status Code: 400; Error Code: AWS.SimpleQueueService.NonExistentQueue; Request ID: cc8cb199-be88-5993-bd58-fca3c9f17110)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:176)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:112)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:770)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:140)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at com.releasebot.processor.Application.main(Application.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

Caused by: org.springframework.messaging.core.DestinationResolutionException: The specified queue does not exist for this wsdl version. (Service: AmazonSQS; Status Code: 400; Error Code: AWS.SimpleQueueService.NonExistentQueue; Request ID: cc8cb199-be88-5993-bd58-fca3c9f17110); nested exception is com.amazonaws.services.sqs.model.QueueDoesNotExistException: The specified queue does not exist for this wsdl version. (Service: AmazonSQS; Status Code: 400; Error Code: AWS.SimpleQueueService.NonExistentQueue; Request ID: cc8cb199-be88-5993-bd58-fca3c9f17110)
at org.springframework.cloud.aws.messaging.support.destination.DynamicQueueUrlDestinationResolver.resolveDestination(DynamicQueueUrlDestinationResolver.java:81)
at org.springframework.cloud.aws.messaging.support.destination.DynamicQueueUrlDestinationResolver.resolveDestination(DynamicQueueUrlDestinationResolver.java:37)
at org.springframework.messaging.core.CachingDestinationResolverProxy.resolveDestination(CachingDestinationResolverProxy.java:88)
at org.springframework.cloud.aws.messaging.listener.AbstractMessageListenerContainer.start(AbstractMessageListenerContainer.java:300)
at org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer.start(SimpleMessageListenerContainer.java:38)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
... 18 common frames omitted

还有其他人遇到过这个吗?任何帮助将不胜感激

4

5 回答 5

27

此错误表示区域us-west-2上不存在指定的队列orderQueue。只需创建它,它应该可以工作。

_@EnableSqs_顺便说一句,使用时无需添加_@EnableAutoConfiguration_.

于 2015-01-22T08:46:36.137 回答
7

阿兰的回答是正确的。此错误表明该队列在区域 us-west-2 中不存在。原因之一可能是 AWS Java 开发工具包使用 us-east-1 作为默认区域。来自 AWS 文档http://docs.aws.amazon.com/java-sdk/latest/developer-guide/java-dg-region-selection.html

如果您未在代码中指定区域,AWS SDK for Java 使用 us-east-1 作为默认区域。但是,AWS 管理控制台默认使用 us-west-2。因此,在将 AWS 管理控制台与您的开发结合使用时,请务必在您的代码和控制台中指定相同的区域。

setRegion()您可以使用或对象的setEndpoint()方法在客户端中专门设置区域或端点AmazonSQSClient。请参阅http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/sqs/AmazonSQS.html#setEndpoint-java.lang.String-

有关区域和端点的列表,请参阅http://docs.aws.amazon.com/general/latest/gr/rande.html#sqs_region

于 2016-08-22T14:48:52.447 回答
5

尝试使用队列的 URL,而不是名称。

于 2016-04-15T02:37:34.533 回答
1

我在尝试使用命令行获取队列 URL时遇到了同样的问题。看看我有什么:

 A client error (AWS.SimpleQueueService.NonExistentQueue) occurred when calling the GetQueueUrl operation: The specified queue does not exist for this wsdl version.

不得不运行这个:

$aws configure

并在提示“默认区域名称[...]:”下输入了我的队列所属的区域。然后错误消失了。

所以仔细检查你的配置;)

于 2016-06-20T19:24:32.073 回答
0

在重新创建同名队列后,我也遇到了这个错误,创建一个新队列是直接的解决方案,因为我不确定在新的 ARN 附加之前需要多长时间。

于 2020-08-21T20:05:48.410 回答