Support Questions
Find answers, ask questions, and share your expertise

Unable to send Kafka message using simple java client

Unable to send Kafka message using simple java client

Hi,

I am trying to send kafka message using simple java client , But I am facing connection issue.

Error : org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.

I have attached java producer client

simpleproducer2.txt

I could able to connect broker

and listener property is PLAINTEXT://0.0.0.0:6667

Can any one let me what I am missing ?

and let me know any details you required.

2 REPLIES 2

Re: Unable to send Kafka message using simple java client

Expert Contributor

Hi @Gobi Subramani,

Is it normal that in your code?:

String node = "x.x.x.x:6667";

I think it should be an ip or hostname.

Michel

Re: Unable to send Kafka message using simple java client

New Contributor

@Gobi Subramani, I tested the code snippet that you attached and it works fine. You just need to make sure that you set correctly the topic name (KafkaClient.TOPIC in your code) and bootstrap servers (node field in your code).

To test your code on your local computer you must set the field node=localhost:9092. You can start a console consumer to verify that the code is running correctly using the command:

KAFKA_HOME/bin/kafka-console-consumer.sh --zookeeper localhost:2181 --from-beginning --topic'