Object
# File lib/amq/client/async/consumer.rb, line 39 39: def initialize(channel, queue, consumer_tag = self.class.tag_generator.generate_for(queue), exclusive = false, no_ack = false, arguments = {}, no_local = false, &block) 40: @callbacks = Hash.new 41: 42: @channel = channel || raise(ArgumentError, "channel is nil") 43: @connection = channel.connection || raise(ArgumentError, "connection is nil") 44: @queue = queue || raise(ArgumentError, "queue is nil") 45: @consumer_tag = consumer_tag 46: @exclusive = exclusive 47: @no_ack = no_ack 48: @arguments = arguments 49: 50: @no_local = no_local 51: 52: self.register_with_channel 53: self.register_with_queue 54: end
Acknowledge a delivery tag. @return [Consumer] self
@api public @see bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.8.3.13.)
# File lib/amq/client/async/consumer.rb, line 114 114: def acknowledge(delivery_tag) 115: @channel.acknowledge(delivery_tag) 116: 117: self 118: end
Called by associated connection object when AMQP connection has been re-established (for example, after a network failure).
@api plugin
# File lib/amq/client/async/consumer.rb, line 186 186: def auto_recover 187: self.exec_callback_yielding_self(:before_recovery) 188: self.resubscribe 189: self.exec_callback_yielding_self(:after_recovery) 190: end
Defines a callback that will be executed after TCP connection is recovered after a network failure but before AMQP connection is re-opened. Only one callback can be defined (the one defined last replaces previously added ones).
@api public
# File lib/amq/client/async/consumer.rb, line 156 156: def before_recovery(&block) 157: self.redefine_callback(:before_recovery, &block) 158: end
# File lib/amq/client/async/consumer.rb, line 82 82: def cancel(nowait = false, &block) 83: @connection.send_frame(Protocol::Basic::Cancel.encode(@channel.id, @consumer_tag, nowait)) 84: self.clear_callbacks(:delivery) 85: self.clear_callbacks(:consume) 86: 87: self.unregister_with_channel 88: self.unregister_with_queue 89: 90: if !nowait 91: self.redefine_callback(:cancel, &block) 92: @channel.consumers_awaiting_cancel_ok.push(self) 93: end 94: 95: self 96: end
# File lib/amq/client/async/consumer.rb, line 63 63: def consume(nowait = false, &block) 64: @connection.send_frame(Protocol::Basic::Consume.encode(@channel.id, @queue.name, @consumer_tag, @no_local, @no_ack, @exclusive, nowait, @arguments)) 65: self.redefine_callback(:consume, &block) 66: 67: @channel.consumers_awaiting_consume_ok.push(self) 68: 69: self 70: end
# File lib/amq/client/async/consumer.rb, line 57 57: def exclusive? 58: !!@exclusive 59: end
# File lib/amq/client/async/consumer.rb, line 209 209: def handle_cancel_ok(cancel_ok) 210: @consumer_tag = nil 211: 212: # detach from object graph so that this object will be garbage-collected 213: @queue = nil 214: @channel = nil 215: @connection = nil 216: 217: self.exec_callback_once(:cancel, cancel_ok) 218: end
@private
# File lib/amq/client/async/consumer.rb, line 146 146: def handle_connection_interruption(method = nil) 147: self.exec_callback_yielding_self(:after_connection_interruption) 148: end
# File lib/amq/client/async/consumer.rb, line 205 205: def handle_consume_ok(consume_ok) 206: self.exec_callback_once(:consume, consume_ok) 207: end
Implementation
# File lib/amq/client/async/consumer.rb, line 201 201: def handle_delivery(basic_deliver, metadata, payload) 202: self.exec_callback(:delivery, basic_deliver, metadata, payload) 203: end
Defines a callback that will be executed after TCP connection is interrupted (typically because of a network failure). Only one callback can be defined (the one defined last replaces previously added ones).
@api public
# File lib/amq/client/async/consumer.rb, line 140 140: def on_connection_interruption(&block) 141: self.redefine_callback(:after_connection_interruption, &block) 142: end
# File lib/amq/client/async/consumer.rb, line 100 100: def on_delivery(&block) 101: self.append_callback(:delivery, &block) 102: 103: self 104: end
Defines a callback that will be executed when AMQP connection is recovered after a network failure.. Only one callback can be defined (the one defined last replaces previously added ones).
@api public
# File lib/amq/client/async/consumer.rb, line 170 170: def on_recovery(&block) 171: self.redefine_callback(:after_recovery, &block) 172: end
@return [Consumer] self
@api public @see bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.8.3.14.)
# File lib/amq/client/async/consumer.rb, line 125 125: def reject(delivery_tag, requeue = true) 126: @channel.reject(delivery_tag, requeue) 127: 128: self 129: end
Used by automatic recovery code. @api plugin
# File lib/amq/client/async/consumer.rb, line 74 74: def resubscribe(&block) 75: @connection.send_frame(Protocol::Basic::Consume.encode(@channel.id, @queue.name, @consumer_tag, @no_local, @no_ack, @exclusive, block.nil?, @arguments)) 76: self.redefine_callback(:consume, &block) if block 77: 78: self 79: end
# File lib/amq/client/async/consumer.rb, line 254 254: def register_with_channel 255: @channel.consumers[@consumer_tag] = self 256: end
# File lib/amq/client/async/consumer.rb, line 258 258: def register_with_queue 259: @queue.consumers[@consumer_tag] = self 260: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.