You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Manikumar Reddy (JIRA)" <ji...@apache.org> on 2014/07/18 06:59:05 UTC

[jira] [Commented] (KAFKA-1192) Enable DumpLogSegments tool to deserialize messages

    [ https://issues.apache.org/jira/browse/KAFKA-1192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14066021#comment-14066021 ] 

Manikumar Reddy commented on KAFKA-1192:
----------------------------------------

Some points

1. Users need to provide customized Decoder class. This is used for deserialization of messages. If no Decoder is provided, default StringDecoder will be used. Customized Decoder jar should be available in kafka/libs directory.


2. Initially I thought of using kafka.serializer.Decoder trait for Decoder classes.
    But this class is parameterized with type. 
    How to instantiate this class inside DumpLogSegments without knowing type a priori? User will pass only implementation class name.


3. Can we create new Decoder trait, which takes byte array and returns Object.?
   User can implement this trait and decode their object. DumpLogSegments will
   print the toString() of the Object.
   
  {code}
   kafka.tools
    trait Decoder {
       def fromBytes(bytes: Array[Byte]]): Object
    }

    class StringDecoder() extends Decoder {
        def fromBytes(bytes: Array[Byte]): Object = {  
             new String(bytes, "UTF-8")
       }
     }
  
     
    class MyDecoder() extends Decoder {
        def fromBytes(bytes: Array[Byte]): Object = {  
             //
             //
             //
       }
     }
   {code}


4.  Topics can have different types of messages. So it the responsibility of the decoder class to decode the different types of messages of same topic.

> Enable DumpLogSegments tool to deserialize messages
> ---------------------------------------------------
>
>                 Key: KAFKA-1192
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1192
>             Project: Kafka
>          Issue Type: Bug
>          Components: tools
>            Reporter: Guozhang Wang
>            Assignee: Manikumar Reddy
>              Labels: newbie
>
> Currently the DumpLogSegments tool reads the message payloads as strings by default, which will not display the messages correctly if the messages are deserialized with another class. By enablding deserialization with a customized class we can use this tool to debug more issues where I need to read the message content.



--
This message was sent by Atlassian JIRA
(v6.2#6252)