Some suggestions:
         Check the existence of the topic.
         Check the firewall of the broker... Try telnet or something to
make sure it's available.
         Try run the producer on the broker machine.

Since you get this error, this code is functioning. I think it's some
configuration and parameter stuff leading to this problem.

On Tue, Aug 4, 2015 at 11:21 AM, David Li <da...@stargazer.com.sg> wrote:

> Hi I have a very simple code to just send out one message, the topic is
> created automatically, but the message just cannot be sent out. I also
> tried to change the configuration, the result is still the same. Sorry to
> bother you all with this silly question.
>
> For your information, the kafka server is running on a docker container,
> which is run in a ubuntu server vm. The test class is run from IntelliJ
> IDEA on the host, which is a amc os x.
>
> public static void main(String[] args) {
>         String topic = "test3";
>
>         Properties props = new Properties();
>         props.put("serializer.class", "kafka.serializer.StringEncoder");
>         props.put("metadata.broker.list", "192.168.144.10:29092");
> //        props.put("retry.backoff.ms", "1000");
> //        props.put("message.send.max.retries", "10");
> //        props.put("topic.metadata.refresh.interval.ms", "0");
>
>         Producer<Integer, String> producer = new Producer<Integer,
> String>(new ProducerConfig(props));
>
>         int messageNo = 1;
>         String messageStr = new String("Message_" + messageNo);
>         producer.send(new KeyedMessage<Integer, String>(topic,
> messageStr));
>     }
>

Reply via email to