コード例 #1
0
 public void publish(byte[] event, String Id) throws ExecutionException, InterruptedException {
   logger.debug("Send message");
   RecordMetadata m =
       kafkaProducer.send(new ProducerRecord<String, byte[]>("events", Id, event)).get();
   System.out.println("Message produced, offset: " + m.offset());
   System.out.println("Message produced, partition : " + m.partition());
   System.out.println("Message produced, topic: " + m.topic());
 }
コード例 #2
0
ファイル: ProducerExample.java プロジェクト: titainic/hadoop
 public void onCompletion(RecordMetadata recordMetadata, Exception e) {
   if (e != null) {
     System.out.println("Error producing to topic " + recordMetadata.topic());
     e.printStackTrace();
   }
 }