|o||Provides an object-oriented API for consuming messages.|
|o||Provides Kafka FETCH and OFFSETS requests.|
|o||Supports parsing the Apache Kafka 0.8 Wire Format protocol.|
|o||Works with 64-bit elements of the Kafka Wire Format protocol on 32 bit systems.|
Array returned by offsets contains offset integers.
Array returned by fetch contains objects of Kafka::Message class.
Creates a new consumer client object. Returns the created Kafka::Consumer object.
new() takes arguments in key-value pairs. The following arguments are recognized:
Connection => $connection $connection is the Kafka::Connection object responsible for communication with the Apache Kafka cluster. CorrelationId => $correlation_id Optional, default is undef.
An exception is thrown if CorrelationId sent with request does not match CorrelationId received in response.
ClientId => $client_id This is a user supplied identifier (string) for the client application. MaxWaitTime => $max_time The maximum amount of time (ms) to wait when no sufficient data is available at the time the request was issued.
Optional, default is $DEFAULT_MAX_WAIT_TIME.
$DEFAULT_MAX_WAIT_TIME is the default time that can be imported from the Kafka module.
The $max_time must be a positive integer.
MinBytes => $min_bytes The minimum number of bytes of messages that must be available to give a response. If the client sets this to $MIN_BYTES_RESPOND_IMMEDIATELY the server will always respond immediately. If it is set to $MIN_BYTES_RESPOND_HAS_DATA, the server will respond as soon as at least one partition has at least 1 byte of data or the specified timeout occurs. Setting higher values in combination with the bigger timeouts allows reading larger chunks of data.
Optional, int32 signed integer, default is $MIN_BYTES_RESPOND_IMMEDIATELY.
$MIN_BYTES_RESPOND_IMMEDIATELY, $MIN_BYTES_RESPOND_HAS_DATA are the defaults that can be imported from the Kafka module.
The $min_bytes must be a non-negative int32 signed integer.
MaxBytes => $max_bytes The maximum bytes to include in the message set for this partition.
Optional, int32 signed integer, default = $DEFAULT_MAX_BYTES (1_000_000).
The $max_bytes must be more than $MESSAGE_SIZE_OVERHEAD (size of protocol overhead - data added by Kafka wire protocol to each message).
$DEFAULT_MAX_BYTES, $MESSAGE_SIZE_OVERHEAD are the defaults that can be imported from the Kafka module.
MaxNumberOfOffsets => $max_number Limit the number of offsets returned by Kafka.
That is a non-negative integer.
Optional, int32 signed integer, default = $DEFAULT_MAX_NUMBER_OF_OFFSETS (100).
$DEFAULT_MAX_NUMBER_OF_OFFSETS is the default that can be imported from the Kafka module.
The following methods are defined for the Kafka::Consumer class:
fetch( $topic, $partition, $start_offset, $max_size )
Get a list of messages to consume one by one up to $max_size bytes.
Returns the reference to array of the Kafka::Message objects.
fetch() takes the following arguments:
offsets( $topic, $partition, $time, $max_number )
$topic The $topic must be a normal non-false string of non-zero length. $partition The $partition must be a non-negative integer. $start_offset Offset in topic and partition to start from (64-bit integer). $max_size $max_size is the maximum size of the messages set to return. The argument must be a positive int32 signed integer.
The maximum size of a request limited by MAX_SOCKET_REQUEST_BYTES that can be imported from Kafka module.
Get a list of valid offsets up to $max_number before the given time.
Returns reference to array of the offset integers (Math::BigInt integers on 32 bit system).
offsets() takes the following arguments:
$topic The $topic must be a normal non-false string of non-zero length. $partition The $partition must be a non-negative integer. $time Get offsets before the given time (in milliseconds since UNIX Epoch).
The argument must be a positive number.
The special values $RECEIVE_LATEST_OFFSET (-1), $RECEIVE_EARLIEST_OFFSETS (-2) are allowed.
$RECEIVE_LATEST_OFFSET, $RECEIVE_EARLIEST_OFFSETS are the defaults that can be imported from the Kafka module.
$max_number $max_number is the maximum number of offsets to retrieve.
Optional. The argument must be a positive int32 signed integer.
When error is detected, an exception, represented by object of Kafka::Exception::Consumer class, is thrown (see Kafka::Exceptions).
code and a more descriptive message provide information about thrown exception. Consult documentation of the Kafka::Exceptions for the list of all available methods.
Invalid argument Invalid argument passed to a new constructor or other method. Cant send Request cannot be sent. Cant recv Response cannot be received. Cant bind TCP connection cant be established on the given host and port. Cant get metadata Failed to obtain metadata from Kafka servers. Leader not found Missing information about server-leader in metadata. Mismatch CorrelationId CorrelationId of response doesnt match one in request. There are no known brokers Resulting metadata has no information about cluster brokers. Cant get metadata Received metadata has incorrect internal structure.
The basic operation of the Kafka package modules:
Kafka::Int64 - functions to work with 64 bit elements of the protocol on 32 bit systems.
Kafka::Internals - internal constants and functions used by several package modules.
Main page at <http://kafka.apache.org/>
Sergey Gladkov, <firstname.lastname@example.org>
Copyright (C) 2012-2013 by TrackingSoft LLC.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|perl v5.20.3||KAFKA::CONSUMER (3)||2015-02-06|