class RackRabbit::Adapter::Bunny
Attributes
channel[RW]
connection[RW]
Public Instance Methods
ack(delivery_tag)
click to toggle source
# File lib/rack-rabbit/adapter/bunny.rb, line 51 def ack(delivery_tag) channel.acknowledge(delivery_tag, false) end
connect()
click to toggle source
# File lib/rack-rabbit/adapter/bunny.rb, line 13 def connect return if connected? @connection = ::Bunny.new(connection_options) connection.start @channel = connection.create_channel channel.prefetch(1) end
connected?()
click to toggle source
# File lib/rack-rabbit/adapter/bunny.rb, line 26 def connected? !@connection.nil? end
disconnect()
click to toggle source
# File lib/rack-rabbit/adapter/bunny.rb, line 21 def disconnect channel.close unless channel.nil? connection.close unless connection.nil? end
publish(payload, properties)
click to toggle source
# File lib/rack-rabbit/adapter/bunny.rb, line 41 def publish(payload, properties) exchange = get_exchange(properties.delete(:exchange), properties.delete(:exchange_type)) exchange ||= channel.default_exchange exchange.publish(payload || "", properties) end
reject(delivery_tag)
click to toggle source
# File lib/rack-rabbit/adapter/bunny.rb, line 55 def reject(delivery_tag) channel.reject(delivery_tag, false) end
subscribe(options = {}) { |message| ... }
click to toggle source
# File lib/rack-rabbit/adapter/bunny.rb, line 30 def subscribe(options = {}, &block) queue = get_queue(options.delete(:queue)) || channel.queue("", :exclusive => true) exchange = get_exchange(options.delete(:exchange), options.delete(:exchange_type)) if exchange queue.bind(exchange, :routing_key => options.delete(:routing_key)) end queue.subscribe(options) do |delivery_info, properties, payload| yield Message.new(delivery_info.delivery_tag, properties, payload, self) end end
with_reply_queue() { |queue("", :exclusive => true, :auto_delete => true)| ... }
click to toggle source
# File lib/rack-rabbit/adapter/bunny.rb, line 47 def with_reply_queue(&block) yield channel.queue("", :exclusive => true, :auto_delete => true) end
Private Instance Methods
get_exchange(ex = :default, type = :direct)
click to toggle source
get_queue(q)
click to toggle source
# File lib/rack-rabbit/adapter/bunny.rb, line 74 def get_queue(q) case q when ::Bunny::Queue then q when Symbol, String then channel.queue(q) else nil end end