[英]Java Kafka Consumer Processing Binary Image Data
I'm new to Kafka and currently have a need to extract binary image data.我是 Kafka 新手,目前需要提取二进制图像数据。 I'm currently using a KafkaAvroDeserializer.
我目前正在使用 KafkaAvroDeserializer。 The key and values of the ConsumerRecord<byte[], byte[]> is:
ConsumerRecord<byte[], byte[]> 的键和值是:
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如果您使用的是 Avro Deserializer,那么您不会使用 byte arrays 作为记录类型,您可以使用
ConsumerRecord<GenericRecord, GenericRecord>
,然后从数据中提取适当的字段
Otherwise, if you only needed byte arrays, the producer would use the ByteArraySerializer which wouldn't be compatible with the Avro Deserializer否则,如果您只需要字节 arrays,则生产者将使用与 Avro Deserializer 不兼容的 ByteArraySerializer
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.