code: public static byte[] createPayload(List<Message> messageList, Compression compression) throws IOException {
          ByteArrayDataOutput out = new ByteArrayDataOutputStream(outputStream.get());
          for (Message message : messageList) {
              message.write(out);
          }
  
          return compression.compress(out.toByteArray());
      }
docs: Create compressed byte[] from the list of messages. Each message contains
  byte[] as its message body, so, this method is simply flattening byte[]
  for all messages in the messageList
  
  @param messageList a list of messages for payload
  @param compression Compression method to be applied to the payload
  @return A byte array that encodes the build payload
  @throws IOException