问题描述
使用时,可以通过设置kafka.compression.codec属性来设置编码解码器
When using kafka, I can set a codec by setting the kafka.compression.codec property of my kafka producer.
假设我在我的生产者中使用snappy压缩,当使用kafka消费者消费来自kafka的消息时,我应该做一些解码数据snappy或是kafka消费者的某些内置功能?
Suppose I use snappy compression in my producer, when consuming the messages from kafka using some kafka-consumer, should I do something to decode the data from snappy or is it some built-in feature of kafka consumer?
在我找不到任何与kafka消费者编码相关的属性(它只与生产者有关)。
In the relevant documentation I could not find any property that relates to encoding in kafka consumer (it only relates to the producer).
有人可以清除这个?
推荐答案
根据我的理解,解压缩由消费者自己处理。如他们的官方wiki页面中提到的
消费者迭代器透明地解压缩压缩数据并且只返回一个未压缩的消息
As per my understanding goes the de-compression is taken care by the Consumer it self. As mentioned in their official wiki pageThe consumer iterator transparently decompresses compressed data and only returns an uncompressed message
如文章中所述,消费者的工作方式如下
As found in this article the way consumer works is as follows
http://kafka.apache.org/documentation.html\">结束批量压缩,其中写道:
And also in the doc page under End-to-end Batch Compression its written that
看起来解压缩部分在消费者中处理它自己所有你需要做的是提供有效/支持的压缩类型使用 compression.codec
ProducerConfig属性,同时创建生产者。我找不到任何例子或解释,它说,在消费者解压缩的任何方法。如果我错了,请更正我。
So it appears that the decompression part is handled in the consumer it self all you need to do is to provide the valid / supported compression type using the compression.codec
ProducerConfig attribute while creating the producer. I couldn't find any example or explanation where it says any approach for decompression in the consumer end. Please correct me if I am wrong.
这篇关于Kafka消息编解码器 - 压缩和解压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!