在Kafka Client 1.1.0中,放置了一个不允许在partition
中将ProducerRecord
用作负数的检查。
但是我在kafka客户端0.10.0中没有在ProducerRecord
中看到任何此类检查。
有人可以让我知道Kafka如何处理0.10中partition
中ProducerRecord
中的负数吗?分区将转换为正数吗?如果是,有人可以指出转换的代码/逻辑吗?
答案 0 :(得分:0)
对于0.10.0 Kafka Producer,该分区的负数也将被拒绝。
检查没有像最近的发行版那样在ProducerRecord
中完成,而是在KafkaProducer.partition()
中完成了,您将获得以下堆栈跟踪:
Exception in thread "main" java.lang.IllegalArgumentException: Invalid partition given with record: -1 is not in the range [0...0].
at org.apache.kafka.clients.producer.KafkaProducer.partition(KafkaProducer.java:717)
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:459)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:430)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:353)