问题描述:kafka中生产的消息超出分区
异常:Exception in thread “main” org.apache.kafka.common.KafkaException: Invalid partition given with record: 1 is not in the range [0…1).
at org.apache.kafka.clients.producer.KafkaProducer.waitOnMetadata(KafkaProducer.java:908)
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:778)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:768)
at com.wenshao.dal.TestProducer.main(TestProducer.java:36)
解决办法:Exception in thread “main” org.apache.kafka.common.KafkaException: Invalid partition given with record: 1 is not in the range [0…1).这个是config下的server.properties中的num.partitions默认为1,可将其增加,如num.partitions=3