lib/amqp/channel.rb in amqp-0.8.0.rc11 vs lib/amqp/channel.rb in amqp-0.8.0.rc12

- old
+ new

@@ -78,11 +78,11 @@ # h2. Error handling # # It is possible (and, indeed, recommended) to handle channel-level exceptions by defining an errback using #on_error: # # @example Queue declaration with incompatible attributes results in a channel-level exception - # AMQP.start("amqp://guest:guest@dev.rabbitmq.com:5672/") do |connection, open_ok| + # AMQP.start("amqp://guest:guest@dev.rabbitmq.com:5672") do |connection, open_ok| # AMQP::Channel.new do |channel, open_ok| # puts "Channel ##{channel.id} is now open!" # # channel.on_error do |ch, close| # puts "Handling channel-level exception" @@ -922,9 +922,35 @@ # @private # @api plugin def find_rpc(name) @rpcs[name] end + + + # + # Backwards compatibility with 0.6.x + # + + # unique identifier + # @deprecated + def self.id + Thread.current[:mq_id] ||= "#{`hostname`.strip}-#{Process.pid}-#{Thread.current.object_id}" + end + + # @private + # @deprecated + def self.default + # TODO: clear this when connection is closed + Thread.current[:mq] ||= AMQP::Channel.new + end + + # Allows for calls to all MQ instance methods. This implicitly calls + # AMQP::Channel.new so that a new channel is allocated for subsequent operations. + # @deprecated + def self.method_missing(meth, *args, &blk) + self.default.__send__(meth, *args, &blk) + end + protected # @private