def receive
Log.debug("Waiting for a message from RabbitMQ")
begin
msg = @connection.receive
rescue ::Stomp::Error::NoCurrentConnection
sleep 1
retry
end
if msg.nil?
raise MessageNotReceived.new(exponential_back_off), "No message received from RabbitMQ."
end
raise "Received a processing error from RabbitMQ: '%s'" % msg.body.chomp if msg.body =~ /Processing error/
if msg.command != 'MESSAGE'
Log.debug("Unexpected '#{msg.command}' frame. Headers: #{msg.headers.inspect} Body: #{msg.body.inspect}")
raise UnexpectedMessageType.new(exponential_back_off),
"Received frame of type '#{msg.command}' expected 'MESSAGE'"
end
Message.new(msg.body, msg, :base64 => @base64, :headers => msg.headers)
end