Class: EstormMessageProcessor::Client
- Inherits:
-
Object
- Object
- EstormMessageProcessor::Client
- Defined in:
- lib/estorm-message-processor/client.rb
Instance Method Summary collapse
- #bunny_send(url, flag, queuename, cmdhash) ⇒ Object
-
#bunny_send_no_close(queuename, cmdhash) ⇒ Object
def bunny_send_no_close(url,flag,queuename,cmdhash).
- #connection ⇒ Object
- #setup_bunny(url, flag) ⇒ Object
Instance Method Details
#bunny_send(url, flag, queuename, cmdhash) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/estorm-message-processor/client.rb', line 24 def bunny_send(url,flag,queuename,cmdhash) @conn,@channel=setup_bunny(url,flag) @queue = @channel.queue(queuename) #cmdhash={'command'=>'sendtemplates', 'promotion'=>self.id.to_s} @channel.default_exchange.publish(cmdhash.to_yaml, :routing_key => @queue.name) @conn.close end |
#bunny_send_no_close(queuename, cmdhash) ⇒ Object
def bunny_send_no_close(url,flag,queuename,cmdhash)
35 36 37 38 39 40 |
# File 'lib/estorm-message-processor/client.rb', line 35 def bunny_send_no_close(queuename,cmdhash) # @conn,@channel=setup_bunny(url,flag) @queue = @channel.queue(queuename) #cmdhash={'command'=>'sendtemplates', 'promotion'=>self.id.to_s} @channel.default_exchange.publish(cmdhash.to_yaml, :routing_key => @queue.name) end |
#connection ⇒ Object
31 32 33 |
# File 'lib/estorm-message-processor/client.rb', line 31 def connection @conn end |
#setup_bunny(url, flag) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/estorm-message-processor/client.rb', line 7 def setup_bunny(url,flag) #maybe save this as global to speed it up. begin @conn = Bunny.new(url) if flag @conn = Bunny.new if !flag @conn.start rescue Bunny::PossibleAuthenticationFailureError => e puts "Could not authenticate as #{@conn.username}" rescue Bunny::TCPConnectionFailed => e puts "BUNNY TCP CONNECTION FAILURE -----RETRY #{e.message}" sleep 3 @conn.start if @conn!=nil end @channel = @conn.create_channel #puts "connected: #{conn.inspect}" [@conn,@channel] end |