python-sqs-listener
python-sqs-listener copied to clipboard
botocore.errorfactory.QueueNameExists when error_queue_name does not share a "prefix" with queue_name
When creating queues via CloudFormation you can allow the queue names to be generated automatically. For example a template with these resources:
MailDeadLetterQueue:
Type: AWS::SQS::Queue
MailQueue:
Type: AWS::SQS::Queue
Properties:
ReceiveMessageWaitTimeSeconds: 20
RedrivePolicy:
deadLetterTargetArn: !Sub ${MailDeadLetterQueue.Arn}
maxReceiveCount: 3
Generates two queues named StackName-MailQueue-UPCWLGTA34SP and StackName-MailDeadLetterQueue-1TD3W1IE8HV2C.
Currently, the codebase only looks for queues that match the queue name as a prefix.
https://github.com/nimbusscale/python-sqs-listener/blob/master/sqs_listener/init.py#L80
Given we are passing the exact queue names to SqsListener, I'd like to update the code so that it looks for each queue individually. Something like this:
sqs = self._session.client('sqs', region_name=self._region_name, endpoint_url=self._endpoint_name, use_ssl=ssl)
try:
self._queue_url = sqs.get_queue_url(QueueName=self._queue_name)['QueueUrl']
mainQueueExists = True
except sqs.exceptions.QueueDoesNotExist:
mainQueueExists = False
try:
self._error_queue_url = sqs.get_queue_url(QueueName=self._error_queue_name)['QueueUrl']
errorQueueExists = True
except sqs.exceptions.QueueDoesNotExist:
errorQueueExists = False
This is just to get the concept apart, I realize that there needs to be support for when AWS_ACCOUNT_ID env var is set and there may be a few other changes to match the rest of the code as well. I'll submit a complete PR assuming this sounds like a direction you are OK with and this project is still active (which it seems to be).
Thanks!
I know it's been a year, but I'm trying to give this project a little attention now. If you don't mind explaining the issue better, it's not clear to me what the problem is you're running into