code: public byte[] write(final SpecificRecord message, final long sequence) {
  
      final String classId = getClassId(message.getClass());
      try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
  
        LOG.log(Level.FINEST, "Serializing message: {0}", classId);
  
        final IMessageSerializer serializer = this.nameToSerializerMap.get(classId);
        if (serializer != null) {
          serializer.serialize(outputStream, message, sequence);
        }
  
        return outputStream.toByteArray();
  
      } catch (final IOException e) {
        throw new RuntimeException("Failure writing message: " + classId, e);
      }
    }
docs: Marshall the input message to a byte array.
  @param message The message to be marshaled into a byte array.
  @param sequence The unique sequence number of the message.