Current state: Accepted
Discussion thread: here
JIRA: KAFKA-13595
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Currently it is not possible to produce records with a null value when using the kafka-console-producer. The kafka-console-producer is an important debugging tool and this would allow producing tombstone records from the CLI rather than depending on external tools such as kcat.
ConsoleProducer will be updated to accept a new property: null.marker
. By default, it will not be set to keep the existing behavior. When set, if any of the fields, key, value or headers (including individual header values, but not header keys) in the input match the marker, a record with that field set to null will be produced. The
Example:
$ ./bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test --property null.marker=NULL >NULL (1) >NULL more content (2) |
Example with key and headers:
$ ./bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test --property null.marker=NULL --property parse.key=true --property parse.headers=true >h0:v0,h1:v1 NULL myvalue (1) >NULL mykey NULL (2) >h0:,h1:v1 NULL NULL (3) >h0:NULL,h1:v1 mykey NULL (4) >NULL:v0 mykey myvalue (5) |
In case the specified null.marker value collides with any of the other flags, an error message will be returned to the user.
This will require small changes in ConsoleProducer/LineMessageReader to accept the new flag and update the generated ProducerRecord accordingly.
None