Skip to content

Instantly share code, notes, and snippets.

@seven1240
Created February 20, 2011 15:45
Show Gist options
  • Save seven1240/836054 to your computer and use it in GitHub Desktop.
Save seven1240/836054 to your computer and use it in GitHub Desktop.
server.rb
====
require 'rubygems'
require 'carrot'
require 'sinatra'
get '/hi' do
"Hello World!"
end
get '/mq' do
q = Carrot.queue('name')
q.publish("hello")
"hello"
end
client.rb
====
require 'rubygems'
require 'carrot'
q = Carrot.queue('name')
while true
msg = q.pop(:ack => true)
if msg
puts "Popping: #{msg}"
q.ack
else
sleep 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment