Sha256: d2443c2b298be3e1279b95acb89a82da61ed7e069133ec76f4159d9c0a74cad0

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8

$:.unshift File.dirname(__FILE__) + '/../lib'
require 'rubygems'
require 'amqp'

# AMQP.start do |amqp|
#   amqp.channel!(1)
#
#   q = amqp.queue.declare(:queue => 'test',
#                          :exclusive => false,
#                          :auto_delete => true)
#
#   q.bind(:exchange => '',
#          :routing_key => 'test_route')
#
#   amqp.basic.consume(:queue => q,
#                      :no_local => false,
#                      :no_ack => true) { |header, body|
#     p ['got', header, body]
#   }
# end

AMQP.start do |amqp|
  amqp.exchange('my_exchange', :topic) do |e|
    e.publish(routing_key, data, :header => 'blah')
  end

  amqp.queue('my_queue').subscribe do |header, body|
    p ['got', header, body]
  end
end

def MQ.method_missing meth, *args, &blk
  (Thread.current[:mq] ||= MQ.new).__send__(meth, *args, &blk)
end

mq = MQ.new
mq.direct.publish('alkjsdf', :key => 'name')
mq.topic # 'amq.topic'
mq.topic('test').publish('some data', :key => 'stock.usd.*')

# amq.queue('user1').bind(amq.topic('conversation.1'))

mq.queue('abc').get {}
mq.queue('abc').peek {}
mq.queue('abc').subscribe { |body|

}

mq.queue('abc').bind(:exchange => mq.topic, :routing_key => 'abc', :nowait => true, :arguments => {})

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amqp-0.7.0 research/api.rb