简体   繁体   中英

How to add custom message deserializer for kafka consumer(using sarama lib)

Serialized Message is getting produced by a java microservice, same message i need to consume in another service written in golang
I am using sarama lib for kafka consumer in golang, I am getting message, but its distorted because of serialization by producing service
Need help to add custom deserializer to consumer for incoming message in Go.

You can try by adding the serialization type in message header before publishing the message.

Let say you want publish a buffered from json string, you can add/set header content-type json. So when you consume the message from another service firstly read the header with key content-type, if the value is json then you use json serialization.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM