All Projects → nielsutrecht → kafka-serializer-example

nielsutrecht / kafka-serializer-example

Licence: MIT license
Example of how to create your own custom serializers for Kafka queues including JSON, Smile and Kryo

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to kafka-serializer-example

eagle
Eagle分布式rpc调用,借助Zookeeper实现服务注册和发现,基于AQS实现高性能连接池,支持分布式追踪、监控、过载保护等配置。提供Spring和SpringBoot插件,方便与Spring和SpringBoot集成。
Stars: ✭ 77 (+208%)
Mutual labels:  kryo
Kaio-machine-learning-human-face-detection
Machine Learning project a case study focused on the interaction with digital characters, using a character called "Kaio", which, based on the automatic detection of facial expressions and classification of emotions, interacts with humans by classifying emotions and imitating expressions
Stars: ✭ 18 (-28%)
Mutual labels:  smile
Myth
Reliable messages resolve distributed transactions
Stars: ✭ 1,470 (+5780%)
Mutual labels:  kryo
Kryo
Java binary serialization and cloning: fast, efficient, automatic
Stars: ✭ 5,247 (+20888%)
Mutual labels:  kryo
spark-util
low-level helpers for Apache Spark libraries and tests
Stars: ✭ 16 (-36%)
Mutual labels:  kryo
Pudding
Pudding 是一款迷你级分布式服务框架
Stars: ✭ 24 (-4%)
Mutual labels:  kryo
protostuff-example
Experimenting protostuff
Stars: ✭ 13 (-48%)
Mutual labels:  kryo

Kafka Custom Serializer Examples with JSON, Smile and Kryo

This example shows how to implement a few different Kafka serialisers (new in Kafka API 0.9.0.0) that can be used to (de)serialize a Java object from/to a Kafka queue. I've written a blog post which you can find here that goes more deeply into explaining how this works.

Building

You can create a runnable jar with Maven: just run mvn clean install and you should find a runnable jar in the target directory.

Running

The main Example class can be run as either a producer (produce option) or consumer (consume option). You also need to specify the format (string,json,smile,kryo) and the Kafka topic used. Optionally you can also specify a Kafka URL.

Command line options:

The command line has 3 mandatory options (produce/consume, the serializer and the Kafka topic) and 1 option option (Kafka host:port, default is Kafka default localhost:9092).

Serializer Description
string StringReaderSerializer: uses basic spring concatenation / splitting
json JacksonReaderSerializer: uses the jackson library to serialize to JSON
smile JacksonReaderSerializer: uses the jackson library to serialize to Smile (binary JSON)
kryo KryoReaderSerializer: uses the kryo library

Examples

java -jar target/kafka-serializer-1.0-SNAPSHOT-jar-with-dependencies.jar produce string test-string Run a producer with StringReaderSerializer writing to the test-string topic

java -jar target/kafka-serializer-1.0-SNAPSHOT-jar-with-dependencies.jar consume json test-json localhost:9100 Run a consumer with JacksonReaderSerializer reading from the test-json topic connecting to Kafka on port 9100

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].