Created
March 15, 2012 01:27
-
-
Save murphybytes/2041022 to your computer and use it in GitHub Desktop.
Heroku hosted iron mq message listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'iron_mq' | |
$stdout.sync = true | |
def write_msg msg | |
puts "*"*10 | |
puts msg | |
puts "*"*10 | |
end | |
write_msg "I am listening" | |
ironmq = IronMQ::Client.new( 'token' => API_TOKEN, 'project_id' => PROJECT_ID ) | |
while true | |
msg = ironmq.messages.get() | |
break if msg.body == 'quit' | |
write_msg msg.body if msg | |
sleep 1 | |
end | |
write_msg "Goodbye" | |
exit(true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment