Example #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());
 }
Example #2
0
 /**
  * Creates a record that can store the kind of data described by the supplied metadata, possibly
  * setting all the fields to the <code>null</code> value.
  *
  * @param metadata the metadata describing the data this record may hold
  * @param nullFields <code>true</code> to indicate that all fields should be set to <code>null
  *     </code>.
  * @throws NullPointerException if the supplied metadata is <code>null</code>.
  */
 public Record(RecordMetadata metadata, boolean nullFields) {
   this.metadata = new RecordMetadata(metadata.getFieldMetadata());
   this.data =
       new ArrayList<Field<? extends Serializable>>(
           Collections.nCopies(this.metadata.getFieldCount(), (Field<Serializable>) null));
   if (nullFields) {
     this.nullFields(this.getMetadata().getFieldNames());
   }
 }