Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get messages off a RabbitMQ... Queue!
require 'httparty'
require 'json'
class QueueInspector
include HTTParty
basic_auth "guest", "guest"
base_uri "http://192.168.0.1:55672"
def messages
body = {'count' => 5,'requeue' => true, 'encoding' => 'auto', 'truncate' => 50000}.to_json
headers = {"Content-Type" => "application/json"}
options = {body: body, headers: headers}
self.class.post "/api/queues/%2f/my_queue/get", options
end
end
response = QueueInspector.new.messages
puts response.code
puts response.body
curl -i -X POST -u guest:guest http://192.168.0.1:55672/api/queues/%2f/my_queue/get -H "Content-Type: application/json" -d '{"count":5,"requeue":true,"encoding":"auto","truncate":50000}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment