I use the following Kafka Docker image: https://hub.docker.com/r/wurstmeister/kafka/
I'm able to start Apache Kafka with the following properties:
<KAFKA_ADVERTISED_HOST_NAME>${local.ip}</KAFKA_ADVERTISED_HOST_NAME>
<KAFKA_ADVERTISED_PORT>${kafka.port}/KAFKA_ADVERTISED_PORT>
<KAFKA_ZOOKEEPER_CONNECT>zookeeper:2181</KAFKA_ZOOKEEPER_CONNECT>
<KAFKA_MESSAGE_MAX_BYTES>15000000</KAFKA_MESSAGE_MAX_BYTES>
but I see the following warning when trying to send the message into the topic:
WARN 9248 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Error while fetching metadata with correlation id 4 : {post.sent=LEADER_NOT_AVAILABLE}
I saw a few articles on the internet that told that this issue can be related to old properties like KAFKA_ADVERTISED_HOST_NAME
and KAFKA_ADVERTISED_PORT
and I should reconfigure to KAFKA_ADVERTISED_LISTENERS
and KAFKA_LISTENERS
. But when I start the Kafka container with the following properties:
<KAFKA_ADVERTISED_LISTENERS>PLAINTEXT://${local.ip}:${kafka.port}</KAFKA_ADVERTISED_LISTENERS>
<KAFKA_LISTENERS>PLAINTEXT://${local.ip}:${kafka.port}</KAFKA_LISTENERS>
<KAFKA_ZOOKEEPER_CONNECT>zookeeper:2181</KAFKA_ZOOKEEPER_CONNECT>
<KAFKA_MESSAGE_MAX_BYTES>15000000</KAFKA_MESSAGE_MAX_BYTES>
my application unable to connect to Kafka:
2018-08-25 16:20:57.407 INFO 17440 --- [ main] o.a.kafka.common.utils.AppInfoParser : Kafka version : 1.1.0
2018-08-25 16:20:57.408 INFO 17440 --- [ main] o.a.kafka.common.utils.AppInfoParser : Kafka commitId : fdcf75ea326b8e07
2018-08-25 16:20:58.513 WARN 17440 --- [| adminclient-1] org.apache.kafka.clients.NetworkClient : [AdminClient clientId=adminclient-1] Connection to node -1 could not be established. Broker may not be available.
2018-08-25 16:20:59.567 WARN 17440 --- [| adminclient-1] org.apache.kafka.clients.NetworkClient : [AdminClient clientId=adminclient-1] Connection to node -1 could not be established. Broker may not be available.
How to properly reconfigure the Docker Kafka in order to be able to use KAFKA_ADVERTISED_LISTENERS
and KAFKA_LISTENERS
?