kafka的producer遇到这个问题:Closing the Kafka producer with timeoutMillis = 0 ms

Andrew Li 发表于: 2018-06-06   最后更新时间: 2018-06-07 01:07:17   17,667 游览

这是我的producer配置:

acks = 1
batch.size = 16384
bootstrap.servers = [192.168.10.10:9092]
buffer.memory = 33554432
client.id =
compression.type = none
connections.max.idle.ms = 540000
enable.idempotence = false
interceptor.classes = null
key.serializer = class org.apache.kafka.common.serialization.StringSerializer
linger.ms = 1
max.block.ms = 60000
max.in.flight.requests.per.connection = 5
max.request.size = 1048576
metadata.max.age.ms = 300000
metric.reporters = []
metrics.num.samples = 2
metrics.recording.level = INFO
metrics.sample.window.ms = 30000
partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner
receive.buffer.bytes = 32768
reconnect.backoff.max.ms = 1000
reconnect.backoff.ms = 50
request.timeout.ms = 30000
retries = 1
retry.backoff.ms = 100
sasl.jaas.config = null
sasl.kerberos.kinit.cmd = /usr/bin/kinit
sasl.kerberos.min.time.before.relogin = 60000
sasl.kerberos.service.name = null
sasl.kerberos.ticket.renew.jitter = 0.05
sasl.kerberos.ticket.renew.window.factor = 0.8
sasl.mechanism = GSSAPI
security.protocol = PLAINTEXT
send.buffer.bytes = 131072
ssl.cipher.suites = null
ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
ssl.endpoint.identification.algorithm = null
ssl.key.password = null
ssl.keymanager.algorithm = SunX509
ssl.keystore.location = null
ssl.keystore.password = null
ssl.keystore.type = JKS
ssl.protocol = TLS
ssl.provider = null
ssl.secure.random.implementation = null
ssl.trustmanager.algorithm = PKIX
ssl.truststore.location = null
ssl.truststore.password = null
ssl.truststore.type = JKS
transaction.timeout.ms = 60000
transactional.id = null
value.serializer = class org.apache.kafka.common.serialization.StringSerializer
发表于 2018-06-06
添加评论

提供下完整的错误额。

Andrew Li -> 半兽人 6年前

已经解决了,我是使用spring的kafka模版发送消息的,每次都新建了一个producer,没有使用到单例创建producer,导致kafka报了异常,阻止新的producer继续创建。kafka抛异常的源码:

private KafkaProducer(ProducerConfig config, Serializer<K> keySerializer, Serializer<V> valueSerializer) {
try {
    log.trace("Starting the Kafka producer");
    ....
} catch (Throwable t) {
     // call close methods if internal objects are already constructed this is to prevent resource leak. see KAFKA-2121
     close(0, TimeUnit.MILLISECONDS, true);
     // now propagate the exception
     throw new KafkaException("Failed to construct kafka producer", t);
}
半兽人 -> Andrew Li 6年前

ok,解决就好。

最后是怎么解决的呢

博主你好! 我也遇到这样的问题,我想歘构建2个不同的producer该怎么解决?

你提个新问题吧,描述一下你的情况。

1.博主 你好!我用springboot框架,创建2个不同地址的producer,只有一个地址的生产者被创建,而另一个确没有创建,一直报这个错误:Closing the Kafka producer with timeoutMillis = 0,Failed to construct kafka producer;这个问题有解决的思路吗?谢谢您!

博主,没有及时回复你,不好意思哈!

https://www.orchome.com/6794
你可以参考下这个例子来解决你的问题。

你提供的信息太少了,如果还没解决,你发起一个新问题,把关键代码带上。
https://www.orchome.com/user/kafka/question?c=I

你的答案

查看kafka相关的其他问题或提一个您自己的问题