报错如下:
java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for mySecondTopic-2:120000 ms has passed since batch creation at org.apache.kafka.clients.producer.internals.FutureRecordMetadata.valueOrError(FutureRecordMetadata.java:98) at org.apache.kafka.clients.producer.internals.FutureRecordMetadata.get(FutureRecordMetadata.java:67) at org.apache.kafka.clients.producer.internals.FutureRecordMetadata.get(FutureRecordMetadata.java:30) at com.shaonaiyi.producer.MySecondProducer.main(MySecondProducer.java:31) Caused by: org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for mySecondTopic-2:120000 ms has passed since batch creation Process finished with exit code 0
org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for mySecondTopic-2:120000 ms has passed since batch creation Process finished with exit code 0
原因:Java API 方式生成者无法与Kafka连接
情况说明:
1、Kafka版本:kafka_2.12-2.3.0
2、部署方式为伪分布式,在一台机器上配置了三个server.properties文件
解决方案:
在每个server.properties文件里面添加一句:
host.name=服务器的ip;
因为我在服务器上配置了域名映射,所以我配的是
host.name=主机名
问题解决!