示例#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
 public void onCompletion(RecordMetadata recordMetadata, Exception e) {
   if (e != null) {
     System.out.println("Error producing to topic " + recordMetadata.topic());
     e.printStackTrace();
   }
 }