我需要使用boto删除队列。我不确定如何删除队列。我试过了,但是没有用:

queue = conn.create_queue(sqs) #sqs is the queue name
conn.delete_queue(queue)

最佳答案

在Boto v2中

>>> import boto.sqs
>>> conn=boto.sqs.connect_to_region('ap-southeast-2')
>>> q = conn.create_queue('foo')
>>> q
Queue(https://ap-southeast-2.queue.amazonaws.com/123456789012/foo)
>>> q.__dict__
{'ResponseMetadata': '', 'url': u'https://ap-southeast-2.queue.amazonaws.com/123456789012/foo', 'CreateQueueResponse': '', 'message_class': <class 'boto.sqs.message.Message'>, 'connection': SQSConnection:ap-southeast-2.queue.amazonaws.com, 'RequestId': u'9bfb9b6d-d9b5-5a29-9ea5-d4dbd5e3ef5a', 'CreateQueueResult': '', 'visibility_timeout': None}
>>> conn.delete_queue(q)
True


在boto3中

>>> import boto3
>>> client = boto3.client('sqs')
>>> q = client.create_queue(QueueName='foo')
>>> q
{u'QueueUrl': 'https://ap-southeast-2.queue.amazonaws.com/123456789012/foo', 'ResponseMetadata': {'HTTPStatusCode': 200, 'RequestId': 'f6531b80-4387-57a2-98fa-54364841c158'}}
>>> client.delete_queue(QueueUrl=q['QueueUrl'])
{'ResponseMetadata': {'HTTPStatusCode': 200, 'RequestId': 'f9d3853c-12f2-598b-ad3c-ca8a1f68754a'}}

关于boto - 如何使用Boto删除队列,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37281941/

10-11 09:14