// Compose message header and payload
headerBuf.writeInt(messageLength);
CompositeByteBuf fullByteBuf = channel.alloc().compositeBuffer(2);
fullByteBuf.addComponent(headerBuf);
fullByteBuf.writerIndex(headerBuf.readableBytes());
if (message != null) {
fullByteBuf.addComponent(message);
fullByteBuf.writerIndex(fullByteBuf.writerIndex() + message.readableBytes());
}