-
-
Save jondeandres/4498329 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
thin start -p 3000 -R test.ru |
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 "sinatra/base" | |
require "amqp" | |
class Test < Sinatra::Base | |
def amqp &blk | |
if ! AMQP.connection | |
AMQP.connection = AMQP.connect "amqp://myAMQPserver.com" | |
end | |
if ! AMQP.connection.connected? | |
AMQP.connection.register_connection_callback do | |
raise "Error couldn't connect" unless AMQP.connection.connected? | |
blk.() | |
end | |
else | |
blk.() | |
end | |
end | |
get "/" do | |
amqp do | |
p "publishing" | |
MQ.queue("test_thin_sinatra_AMQP", :durable => true).publish("coucou") | |
end | |
"o/" | |
end | |
end | |
run Test.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment