I have a really simple producer that I am running through eclipse on my windows local machine... What I really want is to get a message through to kafka, so I will be able to view the broker through zookeeper. Just to see how communication works from end to end... So here goes the code:
Properties props = new Properties();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,"localhost:9020");
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,StringSerializer.class.getName());
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,StringSerializer.class.getName());
KafkaProducer<String,String> producer = new KafkaProducer<String,String>(props);
boolean sync = true;
String topic="mytopic";
String key = "mykey";
String value = "myvalue";
ProducerRecord<String,String> producerRecord = new ProducerRecord<String,String>(topic, key, value);
if (sync) {
producer.send(producerRecord).get();
} else {
producer.send(producerRecord);
}
producer.close();
However after some time I get
Exception in thread "main" java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
at org.apache.kafka.clients.producer.KafkaProducer$FutureFailure.<init>(KafkaProducer.java:437)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:352)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:248)
at kafkaProducer.TestProducer.main(TestProducer.java:30) Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
I have hortonworks sandbox setup, with kafka running but I cannot seem to connect to it. I tried port forwarding in the virtualbox network configurations but still have the same issue. Is there something that I am missing?