What are the 26 additional bytes? That sounds like a header that a
decoder/deserializer is handling with the high level consumer. What class
are you using to deserialize the messages with the high level consumer?

-Ewen

On Fri, Jan 27, 2017 at 10:19 AM, Anjani Gupta <anjani.gu...@salesforce.com>
wrote:

> I am using kafka_2.10-0.8.1 and trying to fetch messages using Simple
> Consumer API. I notice that byte array for message retrieved has 26 junk
> bytes appended at the beginning  of original message sent by producer. Any
> idea what's going on here? This works fine with High level consumer.
>
> This is how my code looks like -
>
> TopicAndPartition topicAndPartition = new TopicAndPartition(topic,
> partition);
>         OffsetFetchResponse offsetFetchResponse = consumer.fetchOffsets(new
> OffsetFetchRequest(GROUP_ID,
>                 Collections.singletonList(topicAndPartition), (short) 0,
> 0,
> CLIENT_ID));
>
>         //Fetch messages from Kafka.
>         FetchRequest req = new FetchRequestBuilder()
>                 .clientId(CLIENT_ID)
>                 .addFetch(topic, partition, readOffset, 1000)
>                 .build();
>         FetchResponse fetchResponse = consumer.fetch(req);
>         for (MessageAndOffset messageAndOffset :
> fetchResponse.messageSet(topicName, partition)) {
>             byte[] message = messageAndOffset.message().payload().array();
>
> }
>
> Here message has additional 26 bytes appended to beginning of array.
>
>
> Thanks,
> Anjani
>

Reply via email to