class Lapine::Exchange
Attributes
conn[R]
connection_name[R]
exchange_type[R]
name[R]
props[R]
Public Class Methods
new(name, properties)
click to toggle source
# File lib/lapine/exchange.rb, line 7 def initialize(name, properties) @name = name @props = properties.dup @connection_name = props.delete(:connection) @exchange_type = props.delete(:type) ObjectSpace.define_finalizer(self, proc { |id| Lapine.config.cleanup_exchange(id) }) end
Public Instance Methods
close()
click to toggle source
# File lib/lapine/exchange.rb, line 33 def close @exchange.channel.close end
connected?()
click to toggle source
# File lib/lapine/exchange.rb, line 15 def connected? @exchange && @exchange.channel && @exchange.channel.connection && @exchange.channel.connection.connected? && @exchange.channel.open? end
exchange()
click to toggle source
# File lib/lapine/exchange.rb, line 23 def exchange @exchange ||= begin conn = Lapine.config.active_connection(connection_name) conn.logger.info "Creating channel for #{self.object_id}, thread: #{Thread.current.object_id}" channel = conn.create_channel Lapine.config.register_channel(self.object_id, channel) Bunny::Exchange.new(channel, exchange_type, name, props) end end