Development environment Solution Kafka Failed to send messages after 3 tries

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.