Class: AMQP::Client::Consumer

Inherits:
Object
  • Object
show all
Defined in:
lib/amqp/client/consumer.rb

Overview

Consumer abstraction

Instance Attribute Summary collapse

Instance Method Summary collapse

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_argsObject (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

#blockObject (readonly)

Returns the value of attribute block.



7
8
9
# File 'lib/amqp/client/consumer.rb', line 7

def block
  @block
end

#channel_idObject (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

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/amqp/client/consumer.rb', line 7

def id
  @id
end

#prefetchObject (readonly)

Returns the value of attribute prefetch.



7
8
9
# File 'lib/amqp/client/consumer.rb', line 7

def prefetch
  @prefetch
end

#queueObject (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

#cancelself

Cancel the consumer

Returns:

  • (self)


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

Returns:

  • (Boolean)


30
31
32
# File 'lib/amqp/client/consumer.rb', line 30

def closed?
  @consume_ok.msg_q.closed?
end

#tagString

Return the consumer tag

Returns:

  • (String)


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