I'm new to Kafka and currently have a need to extract binary image data. I'm currently using a KafkaAvroDeserializer. The key and values of the ConsumerRecord<byte[], byte[]> is:
Key {"prim_key": -99999999, "seq": 1}
value {"beforeImage": null, "afterImage": {"prim_key": -99999999, "seq": 1, "bin_data": {"bytes": ..................}}}
How can I extract the "bytes" raw byte data?
If you're using the Avro Deserializer, then you wouldn't use byte arrays as the record types, you could use ConsumerRecord<GenericRecord, GenericRecord>
, then extract out the appropriate field from the data
Otherwise, if you only needed byte arrays, the producer would use the ByteArraySerializer which wouldn't be compatible with the Avro Deserializer
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.