@Override
  public StringRecord processRecord(Record<User> record) throws RecordProcessingException {

    User user = record.getPayload();
    XContentBuilder builder;
    try {
      builder =
          XContentFactory.jsonBuilder()
              .startObject()
              .field("id", user.getId())
              .field("age", user.getAge())
              .field("gender", user.getGender())
              .endObject();
      return new StringRecord(record.getHeader(), builder.string());
    } catch (IOException e) {
      throw new RecordProcessingException("Failed to map record", e);
    }
  }
コード例 #2
0
 @Override
 public Record processRecord(final Record record) {
   for (long number : numbers) {
     if (record.getHeader().getNumber() == number) {
       return null;
     }
   }
   return record;
 }