code: public byte[] getPayload(GenericRecord inputRecord, String payloadFieldName) {
      ByteBuffer bb = (ByteBuffer) inputRecord.get(payloadFieldName);
      byte[] payloadBytes;
      if (bb.hasArray()) {
        payloadBytes = bb.array();
      } else {
        payloadBytes = new byte[bb.remaining()];
        bb.get(payloadBytes);
      }
      String hexString = new String(payloadBytes, StandardCharsets.UTF_8);
      return DatatypeConverter.parseHexBinary(hexString);
    }
docs: Get payload field from GenericRecord and convert to byte array