public void setMessageHeader(int msgType, int processorType, short msgId) {
    buffer.putInt(Connection.MSG_HEADER_SIZE_OFFSET, Connection.calcHdrSize(size()));
    buffer.put(Connection.MSG_HEADER_TYPE_OFFSET, (byte) (msgType & 0xff));
    buffer.putShort(Connection.MSG_HEADER_ID_OFFSET, msgId);
  }
write the header after the message has been written to the stream
geode-core/src/main/java/org/apache/geode/internal/tcp/MsgOutputStream.java