Class | AMQP::Consumer
In: | lib/amqp/consumer.rb
Parent: | AMQ::Client::Async::Consumer

AMQP consumers are entities that handle messages delivered to them ("push API" as opposed to "pull API") by AMQP broker. Every consumer is associated with a queue. Consumers can be exclusive (no other consumers can be registered for the same queue) or not (consumers share the queue). In the case of multiple consumers per queue, messages are distributed in round robin manner with respect to channel-level prefetch setting).

@see AMQP::Queue @see AMQP::Queue#subscribe @see AMQP::Queue#cancel

### Methods

acknowledge after_connection_interruption after_recovery auto_recover before_recovery callback cancel consume exclusive? inspect new on_connection_interruption on_delivery on_recovery reject resubscribe subscribed? tag_generator tag_generator=

### Attributes

arguments | [R] | @return [Hash] Custom subscription metadata
channel | [R] | @return [AMQP::Channel] Channel this consumer uses
consumer_tag | [R] | @return [String] Consumer tag, unique consumer identifier
queue | [R] | @return [AMQP::Queue] Queue messages are consumed from

### Public Class methods

new(channel, queue, consumer_tag = nil, exclusive = false, no_ack = false, arguments = {}, no_local = false)
tag_generator()

@return [AMQ::Client::ConsumerTagGenerator] Consumer tag generator

tag_generator=(generator)

@param [AMQ::Client::ConsumerTagGenerator] Assigns consumer tag generator that will be used by consumer instances @return [AMQ::Client::ConsumerTagGenerator] Provided argument

### Public Instance methods

acknowledge(delivery_tag)

Acknowledge a delivery tag. @return [Consumer] self

@api public @see bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.8.3.13.)

after_connection_interruption(&block)

Alias for on_connection_interruption

after_recovery(&block)

Alias for on_recovery

auto_recover()

Called by associated connection object when AMQP connection has been re-established (for example, after a network failure).

@api plugin

before_recovery(&block)

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

callback()

Legacy {AMQP::Queue} API compatibility. @private @deprecated

cancel(nowait = false, &block)

@return [AMQP::Consumer] self

consume(nowait = false, &block)

Begin consuming messages from the queue @return [AMQP::Consumer] self

exclusive?()

@return [Boolean] true if this consumer is exclusive (other consumers for the same queue are not allowed)

inspect()

@return [String] Readable representation of relevant object state.

on_connection_interruption(&block)

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

on_delivery(&block)

Register a block that will be used to handle delivered messages.

@return [AMQP::Consumer] self @see AMQP::Queue#subscribe

on_recovery(&block)

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

reject(delivery_tag, requeue = true)

@return [Consumer] self

@api public @see bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.8.3.14.)

resubscribe(&block)

Used by automatic recovery code. @api plugin @return [AMQP::Consumer] self

subscribed?()

{AMQP::Queue} API compatibility.

@return [Boolean] true if this consumer is active (subscribed for message delivery) @api public

[Validate]