I am running this kafka producer example mentioned in its site
The code:
public class TestProducer {
public static void main(String[] args) {
I came across this error in Hortonworks HDP 2.2 where default port is set to 6667. If your kafka server is running on HDP sandbox the resolution is to set metadata.broker.list as 10.0.2.15:6667 Please follow this code.
Properties props = new Properties();
props.put("metadata.broker.list", "10.0.2.15:6667");
props.put("serializer.class", "kafka.serializer.StringEncoder");
//props.put("producer.type","async");
props.put("request.required.acks", "1");
ProducerConfig config = new ProducerConfig(props);
Producer producer = new Producer(config);
try{
producer.send(new KeyedMessage("zerg.hydra", jsonPayload));
producer.close();
}catch(Exception e){
e.printStackTrace();
}