2

I'm able to successfully send messages to a queue in .NET using the AmazonSQSClient clientin the AWSSDK.SQS package.

How can I check to see whether a specific queue exists, and if it doesn't create it?

1
  • Have you tried to just create it again? In Java that works just fine.
    – stdunbar
    Commented Jan 30, 2018 at 23:57

1 Answer 1

9

You'd need to run a check using the AmazonSQSClient.GetQueueUrl (string) method, where the string is the queue name. If the queue doesn't exist, it throws QueueDoesNotExistException. For you to do what you want, you'd need to catch the exception, and then create the queue using that name.

This is all listed in the SQS .Net Documentation here

2
  • So there's no dedicated light-weigh API to check if a specific queue exists? I'd rather not manage exceptions like that as it's going to be an action I'll need to perform continually and at a high rate. I'll have to look into a different work around. Thanks for the information.
    – CorribView
    Commented Jan 31, 2018 at 15:22
  • 6
    You should not need to check whether a queue exists, "continually and at a high rate." It sounds as if you have design assumptions that need to be re-evaluated. If a queue doesn't exist, there are no messages in it, no consumers listening to it, and no producers writing to it. Commented Jan 31, 2018 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.