lib/poseidon/consumer_group.rb
# Convenience method to fetch messages from the broker.
# Round-robins between claimed partitions.
#
# @yield [partition, messages] The processing block
# @yieldparam [Integer] partition The source partition
# @yieldparam [Array<Message>] messages The fetched messages
# @yieldreturn [Boolean] return false to prevent auto-commit
#
# @param [Hash] opts
# @option opts [Boolean] :commit Automatically commit consumed offset (default: true)
# @return [Boolean] true if messages were fetched, false if none could be claimed
#
# @example
#
#   ok = group.fetch do |n, messages|
#     puts "Fetched #{messages.size} messages for partition #{n}"
#   end
#   ok # => true if the block was run, false otherwise
#
# @api public
Convenience method to fetch messages from the broker.
Round-robins between claimed partitions.
Convenience method to fetch messages from the broker . Round - robins between claimed partitions .
def fetch(opts = {})
    checkout(opts) do |consumer|
      yield consumer.partition, consumer.fetch
    end
  end
def fetch ( opts = { } ) checkout ( opts ) do | consumer | yield consumer . partition , consumer . fetch end end
Convenience method to fetch messages from the broker.
Convenience method to fetch messages from the broker .
return false to prevent auto-commit
return false to prevent auto - commit
Boolean
true if messages were fetched, false if none could be claimed
true if messages were fetched false if none could be claimed
Boolean
opts
:commit Automatically commit consumed offset (default: true)
: commit Automatically commit consumed offset ( default : true )
]
<not_specific>
The processing block
The processing block
<not_specific>
None
example
ok = group.fetch do |n, messages| puts "Fetched #{messages.size} messages for partition #{n}" end ok # => true if the block was run, false otherwise
ok = group . fetch do |n messages| puts " Fetched # { messages . size } messages for partition # { n } " end ok # = > true if the block was run false otherwise
api
None