2016-05-17 97 views
2

我需要使用boto刪除隊列。我不確定如何刪除隊列。我試過,但沒有奏效:如何使用boto刪除隊列

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

刪除不必要的內容 – AlBlue

回答

1

在博託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'}} 
+0

偉大的,謝謝。 – user6136315

0

首先,你必須得到隊列 -

queue = conn.create_queue('myqueue') // asuming your queue name 'myqueue' 

然後,你可以簡單地刪除隊列 -

conn.delete_queue(queue)