Producing and consuming JSON in KAFKA
We are going to deploy Apache Kafka 2.10 on our project and communicate via JSON objects between producer and consumer. So far I suppose I need to: Implement a custom serializer to convert JSON into byte array implement a custom deserializer to convert byte array into JSON object Produce the message Read the message in Consumer class Regarding first point, I believe it should be something like this: @Override public byte[] serialize(String topic, T data) { if (data == null) return null; try { ObjectMapper mapper = new ObjectMapper(); return mapper.writeValueAsBytes(data); } catch (Exception e)
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.