Publish null/tombstone message with raw headers

时间:2017-03-22 18:47:11

标签: spring-cloud-stream spring-cloud-dataflow spring-kafka

I am building a Spring Cloud Stream Kafka processor app that will consume raw data with a String key and sometimes a null payload from a Kafka topic. I want to produce to another topic a String key and the null payload (known as a tombstone within Kafka). In order to use raw headers on the message, I need to output a byte[], but if I encode KafkaNull.INSTANCE into a byte[] it will literally output a String of the object hashcode.

If I try to send anything other than a byte[], I can't use raw headers.

What is the correct way to do this? Where would the headers even be if the payload is null? I set producer.headerMode=embeddedHeaders on deploy and that didn't seem to make a difference, still have the hashcode as the payload.

1 个答案:

答案 0 :(得分:1)