zookeep 用的是单机的 kafka配置我也是配的单机的
代码放在项目里面 项目和kafka,zookeep 都是放在服务器上的
application.yml中配置:
spring
kafka:
bootstrap-servers: localhost:9092
kafka server.properties中没有更改或增加任何配置
代码中:
private void send(String topic, String key, String data) {
kafkaTemplate.send(topic, key, data);
}
单纯用了send方法,自己自定义了主题。
运行项目:现在经常报:
异常一:
2019-05-16 18:00:58.326 ERROR [http-nio-9202-exec-64] o.springframework.kafka.support.LoggingProducerListener.onError: 76 ---------Exception thrown when sending a message with key='1558000798326' and payload='{"content":"ok","level":1,"operation":"login","ts":1558000797,"user":"admin"}' to topic d_android_078cc8fb-b3ca-4c61-81e1-ee73bc6d9094_log_1:
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
异常二:
2019-05-16 18:00:57.899 WARN [kafka-producer-network-thread | producer-1] org.apache.kafka.clients.NetworkClient.warn: 246 ---------[Producer clientId=producer-1] Error while fetching metadata with correlation id 45735 : {d_android_bdab2e6e-8e1f-499d-9428-87d5160375a7_log_1=INVALID_REPLICATION_FACTOR, d_android_05e5a80e-3912-40f3-a9f9-ba0751d86daa_log_1=INVALID_REPLICATION_FACTOR, d_android_4a0e8d8e-8ea0-40b6-9501-2b94aee4f1c7_log_1=INVALID_REPLICATION_FACTOR, d_android_078cc8fb-b3ca-4c61-81e1-ee73bc6d9094_log_1=INVALID_REPLICATION_FACTOR, d_android_d85eed68-1396-4d65-a867-6cca533f2e62_log_1=INVALID_REPLICATION_FACTOR, d_android_0419f16a-e330-45e0-a3ad-df26194ce7f6_log_1=INVALID_REPLICATION_FACTOR, d_android_d0a1cf43-eb44-4286-a0ed-464b3efde003_log_1=INVALID_REPLICATION_FACTOR, d_android_c23805b6-be91-44e7-8875-89342127ccef_log_1=INVALID_REPLICATION_FACTOR}
项目偶尔可以正常使用,但是后台日志经常会报这种错误