gpt4 book ai didi

java - 指定的队列不存在 - AWS.SimpleQueueService.NonExistentQueue 与 Spring-Boot

转载 作者:行者123 更新时间:2023-12-01 23:18:24 25 4
gpt4 key购买 nike

我无法在 Spring Boot 应用程序中附加 @SqsListener。它抛出 AWS.SimpleQueueService.NonExistentQueue 异常。

我已经解决了这个问题:Specified queue does not exist据我所知,所有配置都是正确的。

@Component
public class SQSListenerImpl{
@SqsListener(value = Constants.SQS_REQUEST_QUEUE, deletionPolicy = SqsMessageDeletionPolicy.NEVER)
public void listen(String taskJson, Acknowledgment acknowledgment, @Headers Map<String, String> headers) throws ExecutionException, InterruptedException {
//stuff
}

@PostConstruct
private void init(){
final AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
LOGGER.info("Listing all queues in your account.\n");
for (final String queueUrl : sqs.listQueues().getQueueUrls()) {
LOGGER.info(" QueueUrl: " + queueUrl);
}
}
}

应用程序属性

cloud.aws.stack.auto=false
cloud.aws.region.static=ap-southeast-1
logging.level.root=INFO

以上代码的日志:

[requestId: MainThread] [INFO] [SQSListenerImpl] [main]   QueueUrl: https://sqs.ap-southeast-1.amazonaws.com/xxxxx/hello-world
[requestId: MainThread] [INFO] [SQSListenerImpl] [main] QueueUrl: https://sqs.ap-southeast-1.amazonaws.com/xxxxx/some-name2
[requestId: MainThread] [INFO] [SQSListenerImpl] [main] QueueUrl: https://sqs.ap-southeast-1.amazonaws.com/xxxxx/some-name3
[requestId: MainThread] [WARN] [SimpleMessageListenerContainer] [main] Ignoring queue with name 'hello-world': The queue does not exist.; 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: 3c0108aa-7611-528f-ac69-5eb01fasb9f3)
[requestId: MainThread] [INFO] [Http11NioProtocol] [main] Starting ProtocolHandler ["http-nio-8080"]
[requestId: MainThread] [INFO] [TomcatWebServer] [main] Tomcat started on port(s): 8080 (http) with context path ''
[requestId: MainThread] [INFO] [Startup] [main] Started Startup in 11.391 seconds (JVM running for 12.426)

使用的 AWS 凭证位于 ~/.aws/ 目录下。

现在我的问题是,如果 sqs.listQueues() 可以看到队列,那么为什么 @SqsListener 不能?我是否错过了什么或做错了什么?

最佳答案

我像你一样尝试使用 SpringBoot Aws clound 并得到同样的错误。然后我使用完整的 http url 作为队列名称并收到访问被拒绝错误

@SqsListener(value = "https://sqs.ap-southeast-1.amazonaws.com/xxxxx/hello-world")

所以最后,我直接使用AWS SDK从SQS获取消息

关于java - 指定的队列不存在 - AWS.SimpleQueueService.NonExistentQueue 与 Spring-Boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58340604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com