Kafka日志压缩主题将密钥获取为null

时间:2019-09-02 03:18:35

标签: apache-kafka

我在kafka集群中创建了一个日志压缩主题

我像这样开始一个控制台制作人

kafka-console-producer.sh --broker-list localhost:9091 --topic log-compaction-test --property print.key=true --property key.separator=,

它侦听新消息。现在,如果我输入123,abc,它将立即引发以下错误。

>[2019-09-01 22:12:55,897] WARN [Producer clientId=console-producer] Got error produce response with correlation id 5 on topic-partition log-compaction-test-0, retrying (2 attempts left). Error: CORRUPT_MESSAGE (org.apache.kafka.clients.producer.internals.Sender)
[2019-09-01 22:12:56,030] WARN [Producer clientId=console-producer] Got error produce response with correlation id 6 on topic-partition log-compaction-test-0, retrying (1 attempts left). Error: CORRUPT_MESSAGE (org.apache.kafka.clients.producer.internals.Sender)
[2019-09-01 22:12:56,134] WARN [Producer clientId=console-producer] Got error produce response with correlation id 7 on topic-partition log-compaction-test-0, retrying (0 attempts left). Error: CORRUPT_MESSAGE (org.apache.kafka.clients.producer.internals.Sender)
[2019-09-01 22:12:56,243] ERROR Error when sending message to topic log-compaction-test with key: null, value: 8 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.CorruptRecordException: This message has failed its CRC checksum, exceeds the valid size, has a null key for a compacted topic, or is otherwise corrupt.

我也尝试过这种方式。没有运气。

kafka-console-producer.sh --broker-list 0.0.0.0:9091 --topic log-compaction-test --property print.key=true --property key.separator=,

我在做什么错?我确实发送了密钥。卡夫卡以某种方式认为这是空键。

我将docker容器用于zookeeper和kafka经纪人。

1 个答案:

答案 0 :(得分:1)

您使用了错误的属性--property print.key=true。要解析密钥,您必须传递 parse.key = true --property parse.key=true