简体   繁体   中英

Does Kafka Consumer Deserializer have to match Producer Serializer?

Does the deserializer used by a consumer has to match the serializer used by the produced?

If a producer adds JSON values to messages then could the consumer choose to use the ByteArrayDeserializeror , StringDeserializeror JsonDeserializer regardless of which serializer the producer used or does it have to match?

If they have to match, what is the consequence of using a different one? Would this result in an exception, no data or something else?

It has to be compatible , not necessarily the matching pair

ByteArrayDeserializer can consume anything.

StringDeserializer assumes UTF8 encoded strings and might cast other types to strings upon consumption

JsonDeserializer will attempt to parse the message and will fail on invalid JSON

If you used an Avro, Protobuf, Msgpack, etc binary-format consumer then those also attempt to parse the message and will fail if they don't recognize their respective containers

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