Kafka Producer TimeoutException
程序员文章站
2022-04-15 14:05:33
...
web端部分操作会给kafka发送消息,在网络或者kafka出现问题的时候会阻塞进程,影响用户体验
原因:默认超时时间30s
解法方法:添加超时时间设置
props.put("bootstrap.servers", Config.feedback_log_kafka_server)
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer")
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer")
props.put("retries", "3")
//设置超时时间
props.put("request.timeout.ms", "3000")
props.put("acks", "1")
props.put("batch.size", "32768")
application.yml配置
spring:
kafka:
producer:
batch-size: 16384\
buffer-memory: 33554432
key.serializer: org.apache.kafka.common.serialization.StringSerializer
valuess.serializer: org.apache.kafka.common.serialization.StringSerializer
properties:
request:
timeout:
ms:3000