[
https://issues.apache.org/jira/browse/KAFKA-4449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15698020#comment-15698020
]
ASF GitHub Bot commented on KAFKA-4449:
---------------------------------------
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 <[email protected]>
Date: 2016-11-26T09:17:01Z
KAFKA-4449: Add Serializer/Deserializer for POJO
----
> Add Serializer/Deserializer for POJO
> ------------------------------------
>
> Key: KAFKA-4449
> URL: https://issues.apache.org/jira/browse/KAFKA-4449
> Project: Kafka
> Issue Type: Improvement
> Components: clients
> Affects Versions: 0.10.0.1
> Reporter: Jason Guo
> Priority: Minor
> Labels: easyfix, features
> Fix For: 0.10.1.0
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> Currently, there are only build-in serializer/deserializer for basic data
> type. 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
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)