private static ByteBuf writePayload(
			final ByteBufAllocator alloc,
			final long requestId,
			final MessageType messageType,
			final byte[] payload) {

		final int frameLength = HEADER_LENGTH + REQUEST_ID_SIZE + payload.length;
		final ByteBuf buf = alloc.ioBuffer(frameLength + Integer.BYTES);

		buf.writeInt(frameLength);
		writeHeader(buf, messageType);
		buf.writeLong(requestId);
		buf.writeBytes(payload);
		return buf;
	}
private static ByteBuf writePayload ( final ByteBufAllocator alloc , final long requestId , final MessageType messageType , final byte [ ] payload ) { final int frameLength = HEADER_LENGTH + REQUEST_ID_SIZE + payload . length ; final ByteBuf buf = alloc . ioBuffer ( frameLength + Integer . BYTES ) ; buf . writeInt ( frameLength ) ; writeHeader ( buf , messageType ) ; buf . writeLong ( requestId ) ; buf . writeBytes ( payload ) ; return buf ; }
Helper for serializing the messages.

@param alloc			The {@link ByteBufAllocator} used to allocate the buffer to serialize the message into.
@param requestId		The id of the request to which the message refers to.
@param messageType	The {@link MessageType type of the message}.
@param payload		The serialized version of the message.
@return A {@link ByteBuf} containing the serialized message.