GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Kafka::Message(3) User Contributed Perl Documentation Kafka::Message(3)

Kafka::Message - Interface to the Kafka message properties.

This documentation refers to "Kafka::Message" version 0.8010 .

    use 5.010;
    use strict;
    use warnings;

    use Kafka qw(
        $DEFAULT_MAX_BYTES
    );
    use Kafka::Connection;
    use Kafka::Consumer;

    #-- Connection
    my $connection = Kafka::Connection->new( host => 'localhost' );

    #-- Consumer
    my $consumer = Kafka::Consumer->new( Connection  => $connection );

    # The Kafka consumer response has an ARRAY reference type.
    # For the fetch response array has the class name Kafka::Message elements.

    # Consuming messages
    my $messages = $consumer->fetch(
        'mytopic',          # topic
        0,                  # partition
        0,                  # offset
        $DEFAULT_MAX_BYTES  # Maximum size of MESSAGE(s) to receive
    );
    if ( $messages ) {
        foreach my $message ( @$messages ) {
            if( $message->valid ) {
                say 'key        : ', $message->key;
                say 'payload    : ', $message->payload;
                say 'offset     : ', $message->offset;
                say 'next_offset: ', $message->next_offset;
            } else {
                say 'error      : ', $message->error;
            }
        }
    }

    # Closes and cleans up
    undef $consumer;
    undef $connection;

This module is not intended to be used by the end user.

Kafka::Message class implements API for Kafka message.

"fetch" method of the Consumer client returns reference to an array of objects of this class.

The main features of the "Kafka::Message" class are:

Represents Apache Kafka Message structure. Description of the structure is available at <https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-Messagesets>

"new ( \%arg )"

Creates a new "Kafka::Message" object. "new()" takes an argument - HASH reference with the message attributes corresponding to accessors.

"payload"

A simple message received from the Apache Kafka server.

"key"

The key is an optional message key that was used for partition assignment. The key can be an empty string.

"valid"

Boolean value: indicates whether received message is valid or not.

"error"

A description why message is invalid.

"offset"

The offset of the message in the Apache Kafka server.

"next_offset"

The offset of the next message in the Apache Kafka server.

"Attributes"

This holds metadata attributes about the message. The lowest 2 bits contain the compression codec used for the message. The other bits are currently unused.

"HighwaterMarkOffset"

The offset at the end of the log for this partition. This can be used by the client to determine how many messages behind the end of the log they are.

"MagicByte"

This is version id used to allow backwards compatible evolution of the message binary format.

In order to achieve better performance, constructor of this module does not perform validation of arguments.

The basic operation of the Kafka package modules:

Kafka - constants and messages used by the Kafka package modules.

Kafka::Connection - interface to connect to a Kafka cluster.

Kafka::Producer - interface for producing client.

Kafka::Consumer - interface for consuming client.

Kafka::Message - interface to access Kafka message properties.

Kafka::Int64 - functions to work with 64 bit elements of the protocol on 32 bit systems.

Kafka::Protocol - functions to process messages in the Apache Kafka's Protocol.

Kafka::IO - low-level interface for communication with Kafka server.

Kafka::Exceptions - module designated to handle Kafka exceptions.

Kafka::Internals - internal constants and functions used by several package modules.

A wealth of detail about the Apache Kafka and the Kafka Protocol:

Main page at <http://kafka.apache.org/>

Kafka Protocol at <https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol>

Kafka package is hosted on GitHub: <https://github.com/TrackingSoft/Kafka>

Sergey Gladkov, <sgladkov@trackingsoft.com>

Alexander Solovey

Jeremy Jordan

Sergiy Zuban

Vlad Marchenko

Copyright (C) 2012-2013 by TrackingSoft LLC.

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic at <http://dev.perl.org/licenses/artistic.html>.

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.

2015-02-06 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.