简体   繁体   English

Apache Camel:如何创建 AWS SQS 并订阅 SNS 主题

[英]Apache Camel: How I can create AWS SQS and subscribe to SNS topic

I want to create AWS SQS and then subscribe it to an existing SNS topic.我想创建 AWS SQS,然后将其订阅到现有的 SNS 主题。 For use this approach , from Camel documentation, I must know a queue URL.要使用这种方法,从 Camel 文档中,我必须知道一个队列 URL。

//create SQS
from("aws-sqs://MyQueue?amazonSQSClient=#client&delay=5000&maxMessagesPerPoll=5")
.startupOrder(1)
.to("mock:result");

//create SNS and subscribe to SQS
from("direct:start")
.startupOrder(2)
.to("aws-sns://test-camel-sns1?amazonSNSClient=#amazonSNSClient&amazonSQSClient=#amazonSQSClient&subscribeSNStoSQS=true&queueUrl=https://sqs.eu-central-1.amazonaws.com/780410022472/MyQueue");

But I want to use previously created SQS (I know the name of SQS) and I don't know the account value(780410022472).但是我想使用以前创建的 SQS(我知道 SQS 的名称)并且我不知道帐户值(780410022472)。 How can I create SQS and subscribe to SNS without additional information(like an account value) by Camel?如何创建 SQS 并订阅 SNS,而无需 Camel 提供的其他信息(如帐户值)?

If you have access to the AWS account via CLI, you could simply list all existing queues as follows:如果您可以通过 CLI 访问 AWS 账户,您可以简单地列出所有现有队列,如下所示:

aws sqs list-queues

This will return the SQS queue URLs as follows:这将返回 SQS 队列 URL,如下所示:

https://queue.amazonaws.com/80398EXAMPLE/MyQueue

In the above example, the account number would be 80398EXAMPLE .在上面的示例中,帐号将为80398EXAMPLE

You could also get the account details for the current IAM user/role using the following command:您还可以使用以下命令获取当前 IAM 用户/角色的账户详细信息:

aws sts get-caller-identity

This will return the account number with the Account field.这将返回带有Account字段的Account

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM