private void flush(StringBuilder strBuffer) throws IOException {
        long startTime = System.currentTimeMillis();
        flushMutex.lock();
        this.lastMemFlushTime.set(System.currentTimeMillis());
        try {
            swapWriteCache(strBuffer);
            if (logger.isDebugEnabled()) {
                logger.debug(strBuffer.append("[Data Store] StoreKey=").append(storeKey)
                        .append(" Flushing entries.count:")
                        .append(msgMemStoreBeingFlush.getCurMsgCount())
                        .append(" -- getCachedSize ")
                        .append(msgMemStoreBeingFlush.getCurDataCacheSize() / 1024.0 / 1024)
                        .append(" Mb").toString());
                strBuffer.delete(0, strBuffer.length());
            }
        } catch (Throwable e) {
            if (e instanceof IOException) {
                throw (IOException) e;
            } else {
                throw new IOException(e);
            }
        } finally {
            isFlushOngoing.set(false);
            flushMutex.unlock();
            if (logger.isDebugEnabled()) {
                logger.debug(strBuffer.append("[Data Store] StoreKey=")
                        .append(storeKey).append(" Flushed time : ")
                        .append(System.currentTimeMillis() - startTime).append(" ms").toString());
                strBuffer.delete(0, strBuffer.length());
            }
        }
    }
Append message and trigger flush operation.

@param needAdd           whether to add a message
@param isTimeTrigger     whether is timer trigger
@param partitionId       the partitionId for reading messages
@param keyCode           the filter item hash code
@param receivedTime      the received time of message
@param indexEntry        the stored index entry
@param dataLength        the stored data entry length
@param dataEntry         the stored data entry
@param appendResult      the append result

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