Parent

Included Modules

Class Index [+]

Quicksearch

AMQ::Client::Async::Consumer

Attributes

channel[R]

API

queue[R]
consumer_tag[R]
arguments[R]

Public Class Methods

new(channel, queue, consumer_tag = self.class.tag_generator.generate_for(queue), exclusive = false, no_ack = false, arguments = {}, no_local = false, &block) click to toggle source
    # 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
tag_generator() click to toggle source
    # File lib/amq/client/async/consumer.rb, line 30
30:         def self.tag_generator
31:           @tag_generator ||= AMQ::Client::ConsumerTagGenerator.new
32:         end
tag_generator=(generator) click to toggle source
    # File lib/amq/client/async/consumer.rb, line 34
34:         def self.tag_generator=(generator)
35:           @tag_generator = generator
36:         end

Public Instance Methods

acknowledge(delivery_tag) click to toggle source

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
after_connection_interruption(&block) click to toggle source
after_recovery(&block) click to toggle source
Alias for: on_recovery
auto_recover() click to toggle source

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
before_recovery(&block) click to toggle source

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
cancel(nowait = false, &block) click to toggle source
    # 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
consume(nowait = false, &block) click to toggle source
    # 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
exclusive?() click to toggle source
    # File lib/amq/client/async/consumer.rb, line 57
57:         def exclusive?
58:           !!@exclusive
59:         end
handle_cancel_ok(cancel_ok) click to toggle source
     # 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
handle_connection_interruption(method = nil) click to toggle source

@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
handle_consume_ok(consume_ok) click to toggle source
     # 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
handle_delivery(basic_deliver, metadata, payload) click to toggle source

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
on_connection_interruption(&block) click to toggle source

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
on_delivery(&block) click to toggle source
     # 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
on_recovery(&block) click to toggle source

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
Also aliased as: after_recovery
reject(delivery_tag, requeue = true) click to toggle source

@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
resubscribe(&block) click to toggle source

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
run_after_recovery_callbacks() click to toggle source

@private

     # File lib/amq/client/async/consumer.rb, line 176
176:         def run_after_recovery_callbacks
177:           self.exec_callback_yielding_self(:after_recovery)
178:         end
run_before_recovery_callbacks() click to toggle source

@private

     # File lib/amq/client/async/consumer.rb, line 161
161:         def run_before_recovery_callbacks
162:           self.exec_callback_yielding_self(:before_recovery)
163:         end

Protected Instance Methods

register_with_channel() click to toggle source
     # File lib/amq/client/async/consumer.rb, line 254
254:         def register_with_channel
255:           @channel.consumers[@consumer_tag] = self
256:         end
register_with_queue() click to toggle source
     # File lib/amq/client/async/consumer.rb, line 258
258:         def register_with_queue
259:           @queue.consumers[@consumer_tag]   = self
260:         end
unregister_with_channel() click to toggle source
     # File lib/amq/client/async/consumer.rb, line 262
262:         def unregister_with_channel
263:           @channel.consumers.delete(@consumer_tag)
264:         end
unregister_with_queue() click to toggle source
     # File lib/amq/client/async/consumer.rb, line 266
266:         def unregister_with_queue
267:           @queue.consumers.delete(@consumer_tag)
268:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.