lib/amqp/consumer.rb in amqp-1.3.0 vs lib/amqp/consumer.rb in amqp-1.4.0

- old
+ new

@@ -111,17 +111,10 @@ # @return [AMQP::Consumer] self def cancel(nowait = false, &block) @channel.once_open do @queue.once_declared do @connection.send_frame(AMQ::Protocol::Basic::Cancel.encode(@channel.id, @consumer_tag, nowait)) - self.clear_callbacks(:delivery) - self.clear_callbacks(:consume) - self.clear_callbacks(:scancel) - - self.unregister_with_channel - self.unregister_with_queue - if !nowait self.redefine_callback(:cancel, &block) @channel.consumers_awaiting_cancel_ok.push(self) end @@ -302,17 +295,25 @@ def handle_consume_ok(consume_ok) self.exec_callback_once(:consume, consume_ok) end # handle_consume_ok(consume_ok) def handle_cancel_ok(cancel_ok) + self.exec_callback_once(:cancel, cancel_ok) + + self.unregister_with_channel + self.unregister_with_queue + @consumer_tag = nil # detach from object graph so that this object will be garbage-collected @queue = nil @channel = nil @connection = nil - self.exec_callback_once(:cancel, cancel_ok) + self.clear_callbacks(:delivery) + self.clear_callbacks(:consume) + self.clear_callbacks(:cancel) + self.clear_callbacks(:scancel) end # handle_cancel_ok(method) self.handle(AMQ::Protocol::Basic::ConsumeOk) do |connection, frame|