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(url, flag, queuename, cmdhash) ⇒ Object
- #connection ⇒ Object
- #setup_bunny(url, flag) ⇒ Object
Instance Method Details
#bunny_send(url, flag, queuename, cmdhash) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/estorm-message-processor/client.rb', line 20 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(url, flag, queuename, cmdhash) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/estorm-message-processor/client.rb', line 30 def bunny_send_no_close(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) end |
#connection ⇒ Object
27 28 29 |
# File 'lib/estorm-message-processor/client.rb', line 27 def connection @conn end |
#setup_bunny(url, flag) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# 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}" end channel = @conn.create_channel #puts "connected: #{conn.inspect}" [@conn,channel] end |