You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by habren <gi...@git.apache.org> on 2016/11/26 14:34:25 UTC

[GitHub] kafka pull request #2173: KAFKA-4449: Add Serializer/Deserializer for POJO

GitHub user habren opened a pull request:

    https://github.com/apache/kafka/pull/2173

    KAFKA-4449: Add Serializer/Deserializer for POJO

    Currently, there are only build-in serializer/deserializer for basic data type (String, Long, etc). It's better to have serializer/deserializer for POJO.
    
    If we had this, user can serialize/deserialize all of their POJO with it. Otherwise, user may need to create e pair of serializer and deserializer for each kind of POJO, just like the implementation in the stream example PageViewTypeDemo
    https://github.com/apache/kafka/blob/trunk/streams/examples/src/main/java/org/apache/kafka/streams/examples/pageview/PageViewTypedDemo.java
    
    Let's take above streams-example as an example, Serde was created for PageView as below
    
    
            final Serializer<PageView> pageViewSerializer = new JsonPOJOSerializer<>();
            serdeProps.put("JsonPOJOClass", PageView.class);
            pageViewSerializer.configure(serdeProps, false);
    
            final Deserializer<PageView> pageViewDeserializer = new JsonPOJODeserializer<>();
            serdeProps.put("JsonPOJOClass", PageView.class);
            pageViewDeserializer.configure(serdeProps, false);
    
            final Serde<PageView> pageViewSerde = Serdes.serdeFrom(pageViewSerializer, pageViewDeserializer);
    
    
    If we use this POJO serializer/deserializer, the Serde can be created with only one line
        
        Serdes.serdeFrom(RegionCount.class)
        


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/habren/kafka serdes

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/2173.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2173
    
----
commit 40456bd20152d4e37964278b98cb21fb19fbf461
Author: Jason Guo <ha...@163.com>
Date:   2016-11-26T09:17:01Z

    KAFKA-4449: Add Serializer/Deserializer for POJO

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---