Create a new Kafka cluster, under window write a simple producer to do the test, the results encountered a failure to send a message, the code is as follows:
Properties Props = new properties (); Props.put ("Metadata.broker.list", "192.168.1.107:6667"); Props.put ("Serializer.class", "Kafka.serializer.StringEncoder");// Props.put ("Partitioner.class", " Example.producer.SimplePartitioner "); Props.put ("Request.required.acks", "1"); Producerconfig config = new Producerconfig (props); Producer Producer = new producer<string, string> (config); String payload = String.Format ("ayuananybc%s", "Test"); keyedmessage<string, string> data = new keyedmessage<string, string> ("Mytopic", payload); Producer.send (data);
The parameters for viewing Kafka broker are as follows:
So guess is not the local run time do not know Slave1 (192.168.1.107)? Then I added: 192.168.1.107 Slave1 in the hosts.
The result would be:
In fact, the reason is let Kafka know Zookeeper's listening address, we do not modify the hosts, plus the following configuration is also possible:
Development environment Solution Kafka Failed to send messages after 3 tries