简体   繁体   中英

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. For use this approach , from Camel documentation, I must know a queue 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). How can I create SQS and subscribe to SNS without additional information(like an account value) by Camel?

If you have access to the AWS account via CLI, you could simply list all existing queues as follows:

aws sqs list-queues

This will return the SQS queue URLs as follows:

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

In the above example, the account number would be 80398EXAMPLE .

You could also get the account details for the current IAM user/role using the following command:

aws sts get-caller-identity

This will return the account number with the Account field.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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