Created
August 31, 2011 03:33
-
-
Save waynerobinson/1182761 to your computer and use it in GitHub Desktop.
In Rails app
This file contains hidden or 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
| class QueueDaemon | |
| class << self | |
| def start! | |
| Thread.new do | |
| EventMachine.run do | |
| puts "Asimov: Attempting Connection" | |
| AMQP.connect( | |
| :on_possible_authentication_failure => Proc.new {puts("Asimov: Possible Authentication Failure")}, | |
| :on_tcp_connection_failure => Proc.new {puts("Asimov: TCP failure")}, | |
| :on_error => Proc.new {puts("Fucked")}, | |
| :on_tcp_loss => Proc.new {puts("Still Fucked")}, | |
| :on_connection_interrruption => Proc.new {puts("DODGY")} | |
| ) do |connection| | |
| puts "Asimov: Connected to host" | |
| end | |
| puts "Blocked like a boss" | |
| end | |
| end | |
| end | |
| end | |
| end | |
| # In something like config/initializers/queue_daemon.rb | |
| QueueDaemon.start! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment