Sabarish Sathasivan
Sabarish Sathasivan

Reputation: 1276

Apache Kafka Producer error: Failed to send message after 3 tries

We have installed kafka on a Linux Ubuntu server and tested the communication using the batch files - kafka-console-producer.sh and kafka-console-consumer.sh and found that we can publish and receive messages

On a windows machine running on the same network . We wrote a java producer client , whose code is shown

Properties properties = new Properties();
properties.put("metadata.broker.list","192.168.7.1:9092");
properties.put("serializer.class","kafka.serializer.StringEncoder");
ProducerConfig producerConfig = new ProducerConfig(properties);
kafka.javaapi.producer.Producer<String,String> producer = new kafka.javaapi.producer.Producer<String, String>(producerConfig);
KeyedMessage<String, String> message =new KeyedMessage<String, String>("Calamp2","Test message from java program ");
producer.send(message);
producer.close();

When we run the client, we are getting the following error

log4j:WARN No appenders could be found for logger (kafka.utils.VerifiableProperties). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. Failed to send messages after 3 tries.

We tried the following

  1. Pinged the ubuntu machine from Windows machine and it seems to be working fine
  2. Tried the solution from Apache Kafka example error: Failed to send message after 3 tries , but it did not work

One strange thing we observed that when we ran the following command on the server - bin/kafka-topics.sh --list --zookeeper localhost:2181 , We found that topics were created from the Java code , but message was not published

Any help is appreciated

Upvotes: 1

Views: 6147

Answers (1)

Sabarish Sathasivan
Sabarish Sathasivan

Reputation: 1276

We finally figured out the issue... We were running kafka in a hybrid evironment as mentioned in the following post -

https://medium.com/@thedude_rog/running-kafka-in-a-hybrid-cloud-environment-17a8f3cfc284

We changed the host.name to the internal IP and advertised.host.name to external IP. This was the same problem as Kafka 0.8.2.2 - Unable to publish messages

Upvotes: 2

Related Questions