@@ -0,0 +1,1283 @@
+import java.util.Properties;%0Aimport java.util.concurrent.ExecutionException;%0A%0Aimport org.apache.kafka.clients.producer.KafkaProducer;%0Aimport org.apache.kafka.clients.producer.ProducerConfig;%0Aimport org.apache.kafka.clients.producer.ProducerRecord;%0Aimport org.apache.kafka.common.serialization.StringSerializer;%0A%0A/**%0A * An example using the new java client Producer for Kafka 0.8.2%0A * %0A * 2015/02/27%0A * @author Cameron Gregory, http://www.bloke.com/%0A */%0Apublic class TestProducer %7B%0A%09public static void main(String args%5B%5D) throws InterruptedException, ExecutionException %7B%0A%09%09Properties props = new Properties();%0A%09%09props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,%22localhost:9092%22);%0A%09%09props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,StringSerializer.class.getName());%0A%09%09props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,StringSerializer.class.getName());%0A%0A%09%09KafkaProducer%3CString,String%3E producer = new KafkaProducer%3CString,String%3E(props);%0A%09%09%0A%09%09boolean sync = false;%0A%09%09String topic=%22mytopic%22;%0A%09%09String key = %22mykey%22;%0A%09%09String value = %22myvalue%22;%0A%09%09ProducerRecord%3CString,String%3E producerRecord = new ProducerRecord%3CString,String%3E(topic, key, value);%0A%09%09if (sync) %7B%0A%09%09%09producer.send(producerRecord).get();%0A%09%09%7D else %7B%0A%09%09%09producer.send(producerRecord);%0A%09%09%7D%0A%09%09producer.close();%0A%09%7D%0A%7D%0A

Create TestProducer.java