I am using Kafka. This is my code , where i want to send messages to kafka server,Topic name is "west" with message "message1".I'm not getting any error though i haven't seen my sent messages in the topic is there anything wrong here?
class SimpleProducer {
public static void main(String[] args) throws Exception{
Properties props = new Properties();
props.put("bootstrap.servers","172.xxxxxxxxx:9092");
props.put("serializer.class", "kafka.serializer.DefaultEncoder");
props.put("acks", "1");
props.put("retries", 1);
props.put("batch.size", 16384);
props.put("linger.ms", 0);
props.put("client.id", "foo");
props.put("buffer.memory", 33554432);
props.put("timeout.ms", "500");
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.setProperty(ProducerConfig.MAX_BLOCK_MS_CONFIG, "500");
props.setProperty(ProducerConfig.RETRY_BACKOFF_MS_CONFIG, "100");
System.out.println("ready to send msg");
try {
Producer<String, String> producer = new KafkaProducer<String, String>(props);
producer.send(new ProducerRecord<String, String>("west","message1"));
System.out.println("Message sent successfully");
producer.close();
}
catch(Exception e)
{
System.out.println("Messgae doesn't sent successfully");
e.printStackTrace();
}
}
}