def process_request
begin
@request.body.rewind
dest = @request.params[Mongrel::Const::REQUEST_PATH]
case @request_method
when 'PUT'
@frame = StompServer::StompFrame.new
@frame.command = 'SEND'
@frame.body = @request.body.read
@frame.headers['destination'] = dest
if @@queue_manager.enqueue(@frame)
create_response('200','Message Enqueued')
else
create_response('500','Error enqueueing message')
end
when 'GET'
if frame = @@queue_manager.dequeue(dest)
@headers_out['message-id'] = frame.headers['message-id']
create_response('200',frame.body)
else
create_response('404','No messages in queue')
end
else
create_response('500','Invalid Command')
end
rescue Exception => e
puts "err: #{e} #{e.backtrace.join("\n")}"
create_response('500',e)
end
end