pdeva :
I am currently sending data using spring-kafka like this:
val json = objectWriter.writeValueAsString(obj)
kafkaTemplate.send(topic, json)
How do i tell KafkaTemplate to use compress the json using snappy before sending?
Deadpool :
In apache kafka there is producer config compression.type
with valid values
The compression type for all data generated by the producer. The default is none (i.e. no compression). Valid values are none, gzip, snappy, lz4, or zstd
So you can set in producer configs
ProducerConfig.COMPRESSION_TYPE_CONFIG "snappy"
or by using properties
spring.kafka.producer.compression-type= # Compression type for all data generated by the producer.
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=309788&siteId=1