public boolean appendMsg2(AppendResult appendResult, int dataLength,
            int dataCheckSum, byte[] data,
            int msgTypeCode, int msgFlag,
            int partitionId, int sentAddr,
            long receivedTime, int count,
            long waitRetryMs) throws IOException {
        if (this.closed.get()) {
            throw new IllegalStateException(new StringBuilder(512)
                    .append("[Data Store] Closed MessageStore for storeKey ")
                    .append(this.storeKey).toString());
        }
        long messageId = this.idWorker.nextId();
        // build data buffer
        int msgBufLen = DataStoreUtils.STORE_DATA_HEADER_LEN + dataLength;
        final ByteBuffer dataBuffer = ByteBuffer.allocate(msgBufLen);
        dataBuffer.putInt(DataStoreUtils.STORE_DATA_PREFX_LEN + dataLength);
        dataBuffer.putInt(DataStoreUtils.STORE_DATA_TOKER_BEGIN_VALUE);
        dataBuffer.putInt(dataCheckSum);
        dataBuffer.putInt(partitionId);
        dataBuffer.putLong(-1L);
        dataBuffer.putLong(receivedTime);
        dataBuffer.putInt(sentAddr);
        dataBuffer.putInt(msgTypeCode);
        dataBuffer.putLong(messageId);
        dataBuffer.putInt(msgFlag);
        dataBuffer.put(data);
        dataBuffer.flip();
        // build index buffer
        final ByteBuffer indexBuffer =
                ByteBuffer.allocate(DataStoreUtils.STORE_INDEX_HEAD_LEN);
        indexBuffer.putInt(partitionId);
        indexBuffer.putLong(-1L);
        indexBuffer.putInt(msgBufLen);
        indexBuffer.putInt(msgTypeCode);
        indexBuffer.putLong(receivedTime);
        indexBuffer.flip();
        appendResult.putReceivedInfo(messageId, receivedTime);
        boolean appendSuss = true;
        long startTime = System.currentTimeMillis();
        if (this.tubeConfig.isEnableMemStore()) {
            do {
                this.writeCacheMutex.readLock().lock();
                try {
                    appendSuss = this.msgMemStore.appendMsg(msgStoreStatsHolder,
                            partitionId, msgTypeCode, receivedTime, indexBuffer,
                            msgBufLen, dataBuffer, appendResult);
                } finally {
                    this.writeCacheMutex.readLock().unlock();
                }
                if (appendSuss) {
                    msgStoreStatsHolder.addMsgWriteSuccess(msgBufLen,
                            System.currentTimeMillis() - startTime);
                    return true;
                }
                if (triggerFlushAndAddMsg(true, false, partitionId, msgTypeCode,
                        receivedTime, indexBuffer, msgBufLen, dataBuffer, appendResult)) {
                    msgStoreStatsHolder.addMsgWriteSuccess(msgBufLen,
                            System.currentTimeMillis() - startTime);
                    return true;
                }
                ThreadUtils.sleep(waitRetryMs);
            } while (count-- >= 0);
            msgStoreStatsHolder.addMsgWriteFailure();
            return false;
        } else {
            StringBuilder strBuffer =
                    new StringBuilder(TBaseConstants.BUILDER_DEFAULT_SIZE);
            Tuple3<Boolean, Long, Long> appendRet =
                    this.msgFileStore.appendMsg(false, startTime, strBuffer, 1,
                            DataStoreUtils.STORE_INDEX_HEAD_LEN, indexBuffer,
                            msgBufLen, dataBuffer, receivedTime, receivedTime);
            appendResult.putAppendResult(appendRet.getF1(), appendRet.getF2());
            if (appendRet.getF0()) {
                msgStoreStatsHolder.addMsgWriteSuccess(msgBufLen,
                        System.currentTimeMillis() - startTime);
            } else {
                msgStoreStatsHolder.addMsgWriteFailure();
            }
            return appendRet.getF0();
        }
    }
Append msg to store.

@param appendResult    the append result
@param dataLength      the data length
@param dataCheckSum    the check sum of message data
@param data            the message data
@param msgTypeCode     the filter item hash code
@param msgFlag         the message flag
@param partitionId     the partitionId for append messages
@param sentAddr        the address to send the message to
@param receivedTime    the received time of message
@param count           the retry count while full
@param waitRetryMs     the wait duration while retry

@return                the process result
@throws IOException    the exception during processing
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/broker/msgstore/MessageStore.java