Method: RightAws::SqsInterface#force_clear_queue
- Defined in:
- lib/sqs/right_sqs_interface.rb
#force_clear_queue(queue_url) ⇒ Object
Deletes queue then re-creates it (restores attributes also). The fastest method to clear big queue or queue with invisible messages. Return true
or an exception.
sqs.force_clear_queue('http://queue.amazonaws.com/ZZ7XXXYYYBINS/my_awesome_queue') #=> true
PS This function is no longer supported. Amazon has changed the SQS semantics to require at least 60 seconds between queue deletion and creation. Hence this method will fail with an exception.
423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/sqs/right_sqs_interface.rb', line 423 def force_clear_queue(queue_url) queue_name = queue_name_by_url(queue_url) queue_attributes = get_queue_attributes(queue_url) force_delete_queue(queue_url) create_queue(queue_name) # hmmm... The next line is a trick. Amazon do not want change attributes immediately after queue creation # So we do 'empty' get_queue_attributes. Probably they need some time to allow attributes change. get_queue_attributes(queue_url) queue_attributes.each{ |attribute, value| set_queue_attributes(queue_url, attribute, value) } true rescue on_exception end |