gist: 2412 Download_button fork
public
Public Clone URL: git://gist.github.com/2412.git
simple.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$:.unshift File.dirname(__FILE__) + '/../lib'
require 'mq'
 
EM.run do
  
  # open a channel on the AMQP connection
  channel = MQ.new
 
  # declare a queue on the channel
  queue = MQ::Queue.new(channel, 'queue name')
 
  # use the default fanout exchange
  exchange = MQ::Exchange.new(channel, :fanout, 'all queues')
 
  # bind the queue to the exchange
  queue.bind(exchange)
 
  # publish a message to the exchange
  exchange.publish('hello world')
 
  # subscribe to messages from the queue
  queue.subscribe do |headers, msg|
    p [:got, headers, msg]
  end
  
end

Owner

tmm1

Revisions