Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 23rd, 2012  |  syntax: None  |  size: 0.59 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     def publish(urlSearch, routing_key, ws = nil)
  2.       corr_id = rand(10_000_000).to_s
  3.    
  4.       connection = AMQP.connect(@conf)
  5.      
  6.       callback_queue = AMQP::Channel.new(connection).queue("", :exclusive => false)
  7.      
  8.       callback_queue.subscribe(:ack => true) do |header, body|
  9.         header.ack
  10.  
  11.         ws.send body if ws
  12.       end
  13.      
  14.       callback_queue.append_callback(:declare) do
  15.         AMQP::Exchange.default.publish(urlSearch, :routing_key => routing_key, :reply_to => callback_queue.name, :correlation_id => corr_id)
  16.       end
  17.    
  18.       puts "initial message sent"
  19.     end