KafkaTemplate发送消息异常due to 30036 ms has passed since batch creation plus linger time
org.springframework.kafka.core.KafkaProducerException: Failed to send; nested exception is org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for logs_vipfengxiao_c-teach-room_c-tea
org.springframework.kafka.core.KafkaProducerException: Failed to send; nested exception is org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for logs_vipfengxiao_c-teach-room_c-teach-room-0 due to 30036 ms has passed since batch creation plus linger time
原因如下是未配置:
advertised.listeners=PLAINTEXT://192.168.14.140:9092
"PLAINTEXT"表示协议,可选的值有PLAINTEXT和SSL,hostname可以指定IP地址,也可以用"0.0.0.0"表示对所有的网络接口有效,如果hostname为空表示只对默认的网络接口有效
也就是说如果你没有配置advertised.listeners,就使用listeners的配置通告给消息的生产者和消费者,这个过程是在生产者和消费者获取源数据(metadata)。如果都没配置,那么就使用java.net.InetAddress.getCanonicalHostName()返回的值,对于ipv4,基本就是localhost了,然后你的生产者就会一直卡死。可以看到客户端连接127.0.0.1:9092而不是你期望的服务器的地址。
更多推荐
所有评论(0)