Пример #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();
   }
 }