How to remove content type header from kafka messages generated by spring cloud source application source

For the twitter source, it creates a 30-bit header for each kafka message if we use a custom kafka consumer other than @StreamListener(Sink). @StreamListenercorrectly sends messages to the annotated method (no header). The problem is that for each source, the size of the header changes. So, how can I dynamically understand the size of the message header, since I am using the kafka user consumer.? Or How to remove the header for each message.?

UPDATE: -

The following is the message received kafka-console-consumerwhen using a TCP source.

 
  contentType"application/octet-stream"hello world

I just need to get a message. In this case, hello world

+4
source share
3 answers

The setting spring.cloud.stream.default.producer.headerMode=rawin the source will remove the header when reading the message from the consumer.

+1
source

What version of Kafka are you using? The reason I ask is because starting with 0.11, Kafka supports its own headers, and you will no longer have this problem.

+2
source

You can also change this setting to remove the annoying title.

spring.cloud.stream.default.producer.useNativeEncoding=true
0
source

Source: https://habr.com/ru/post/1689999/


All Articles