Method: Aws::SqsInterface#delete_message

Defined in:
lib/sqs/sqs_interface.rb

#delete_message(queue_url, receipt_handle) ⇒ Object

Deletes message from queue. Returns true or an exception. Amazon returns true on deletion of non-existent messages. You must use the receipt handle for a message to delete it, not the message ID.

From the SQS Developer Guide: “It is possible you will receive a message even after you have deleted it. This might happen on rare occasions if one of the servers storing a copy of the message is unavailable when you request to delete the message. The copy remains on the server and might be returned to you again on a subsequent receive request. You should create your system to be idempotent so that receiving a particular message more than once is not a problem. ”

sqs.delete_message('http://queue.amazonaws.com/ZZ7XXXYYYBINS/my_awesome_queue', 'Euvo62/1nlIet...ao03hd9Sa0w==') #=> true


287
288
289
290
291
292
# File 'lib/sqs/sqs_interface.rb', line 287

def delete_message(queue_url, receipt_handle)
  req_hash = generate_request('DeleteMessage', 'ReceiptHandle' => receipt_handle, :queue_url => queue_url)
  request_info(req_hash, SqsStatusParser.new(:logger => @logger))
rescue
  on_exception
end