Class: AMQP::Client::Consumer
- Inherits:
-
Object
- Object
- AMQP::Client::Consumer
- Defined in:
- lib/amqp/client/consumer.rb
Overview
Consumer abstraction
Instance Attribute Summary collapse
-
#basic_consume_args ⇒ Object
readonly
Returns the value of attribute basic_consume_args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#channel_id ⇒ Object
readonly
Returns the value of attribute channel_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#prefetch ⇒ Object
readonly
Returns the value of attribute prefetch.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#cancel ⇒ self
Cancel the consumer.
-
#closed? ⇒ Boolean
True if the consumer is cancelled/closed.
-
#initialize(client:, channel_id:, id:, block:, **settings) ⇒ Consumer
constructor
private
A new instance of Consumer.
-
#tag ⇒ String
Return the consumer tag.
-
#update_consume_ok(consume_ok) ⇒ Object
private
Update the consumer with new metadata after reconnection.
Constructor Details
#initialize(client:, channel_id:, id:, block:, **settings) ⇒ Consumer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Consumer.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/amqp/client/consumer.rb', line 10 def initialize(client:, channel_id:, id:, block:, **settings) @client = client @channel_id = channel_id @id = id @queue = settings.fetch(:queue) @basic_consume_args = settings.fetch(:basic_consume_args) @prefetch = settings.fetch(:prefetch) @consume_ok = settings.fetch(:consume_ok) @block = block end |
Instance Attribute Details
#basic_consume_args ⇒ Object (readonly)
Returns the value of attribute basic_consume_args.
7 8 9 |
# File 'lib/amqp/client/consumer.rb', line 7 def basic_consume_args @basic_consume_args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
7 8 9 |
# File 'lib/amqp/client/consumer.rb', line 7 def block @block end |
#channel_id ⇒ Object (readonly)
Returns the value of attribute channel_id.
7 8 9 |
# File 'lib/amqp/client/consumer.rb', line 7 def channel_id @channel_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/amqp/client/consumer.rb', line 7 def id @id end |
#prefetch ⇒ Object (readonly)
Returns the value of attribute prefetch.
7 8 9 |
# File 'lib/amqp/client/consumer.rb', line 7 def prefetch @prefetch end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
7 8 9 |
# File 'lib/amqp/client/consumer.rb', line 7 def queue @queue end |
Instance Method Details
#cancel ⇒ self
Cancel the consumer
23 24 25 26 |
# File 'lib/amqp/client/consumer.rb', line 23 def cancel @client.cancel_consumer(self) self end |
#closed? ⇒ Boolean
True if the consumer is cancelled/closed
30 31 32 |
# File 'lib/amqp/client/consumer.rb', line 30 def closed? @consume_ok.msg_q.closed? end |
#tag ⇒ String
Return the consumer tag
36 37 38 |
# File 'lib/amqp/client/consumer.rb', line 36 def tag @consume_ok.consumer_tag end |
#update_consume_ok(consume_ok) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Update the consumer with new metadata after reconnection
42 43 44 |
# File 'lib/amqp/client/consumer.rb', line 42 def update_consume_ok(consume_ok) @consume_ok = consume_ok end |