FlushConsumerQueueService有必要吗

版本4.9.1

从ReputMessage Service代码中,我们终于可以找到以下代码“this.fileChannel.write(ByteBuffer.wrapp(data));”已经可以将数据写入磁盘,为什么我们需要FlushConsumerQueueService?

public boolean appendMessage(final byte[] data) { int currentPos = this.wrotePosition.get();

if ((currentPos + data.length) <= this.fileSize) { try { this.fileChannel.position(currentPos); this.fileChannel.write(ByteBuffer.wrap(data)); } catch (Throwable e) { log.error("Error occurred when append message to mappedFile.", e); } this.wrotePosition.addAndGet(data.length); return true; }

return false;

原提问者GitHub用户iamqq23ue

展开
收起
芬奇福贵 2023-05-26 10:29:06 77 分享 版权
1 条回答
写回答
取消 提交回答
  • 对于索引来说每次写入的数据量小但是更新频繁,用 mmap 确实会更好,还有 commitlog 应该用 filechannel。

    个人认为这里主要是避免 os 积累太多的脏页导致 io 抖动

    原回答者GitHub用户lizhimins

    2023-05-26 16:50:58
    赞同 展开评论
问答地址: