gpt4 book ai didi

java - AWS Java SDK SQSlistener 端点问题

转载 作者:行者123 更新时间:2023-11-30 10:16:29 32 4
gpt4 key购买 nike

我正在使用 AWS Java SDK 以及 spring cloud aws 在我的项目中使用 SES 和 SQS。我遇到了一个小问题。当我尝试运行我的应用程序时出现错误:

Error creating bean with name 'simpleMessageListenerContainer' defined in class path resource [org/springframework/cloud/aws/messaging/config/annotation/SqsConfiguration.class]: Invocation of init method failed; nested exception is com.amazonaws.services.sqs.model.AmazonSQSException: Credential should be scoped to a valid region, not 'queue'.

作为序言,在我的 app.properties 文件中,我有一个属性 queue.endpoint=https://queue.amazonaws.com/1234567890/queue-name.fifo 并且从 aws cli 检索端点。

我已阅读 AWS 文档并发现此端点是旧端点。此属性由来自 spring cloud aws 库的 @SqsListener 注释使用。

我设法避免了这个问题,方法是查看我是否在使用旧端点并通过 shell 脚本将其转换为非旧端点,即 https://sqs.us-east-1.amazonaws。 com/123456780/queue-name.fifo

我想知道 spring cloud aws 库在使用遗留端点时是否存在问题。我注意到端点为 https://us-east-2.queue.amazonaws.com/1234567890/queue2-name.fifo 的其他队列没有问题,所以也许它已解析us-east-1 遗留端点不正确?我也不确定是否需要在我的应用程序中完成任何配置才能使用遗留端点。

最佳答案

如果我对问题的理解正确,您的问题是关于 SQS 队列端点没有在端点开头附加 us-east-1。它不是遗留端点。在 AWS 中,某些服务不允许您在端点中指定区域。无论路由到此端点的是什么:https://queue.amazonaws.com/1234567890/queue-name.fifo,都将自动路由到 us-east-1 AWS 中的区域。

这在AWS中与Endpoints相关的文档中有明确提及。 ( Link )

Some services, such as IAM, do not support regions; therefore, their endpoints do not include a region. Some services, such as Amazon EC2, let you specify an endpoint that does not include a specific region, for example, https://ec2.amazonaws.com. In that case, AWS routes the endpoint to us-east-1.

关于java - AWS Java SDK SQSlistener 端点问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50046066/

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