这个load操作发生在启动broker的时候。

RocketMQ之broker读取本地文件数据

所以我们直接进入DefaultMessageStore的load()方法:

   /**
     * 加载数据
     *
     * @throws IOException
     */
    public boolean load() {
        boolean result = true;

        try {
            boolean lastExitOK = !this.isTempFileExist();
            log.info("last shutdown {}", (lastExitOK ? "normally" : "abnormally"));

            // load 定时进度
            // 这个步骤要放置到最前面,从CommitLog里Recover定时消息需要依赖加载的定时级别参数
            // slave依赖scheduleMessageService做定时消息的恢复
            if (null != scheduleMessageService) {
                result = result && this.scheduleMessageService.load();
            }

            // load Commit Log
            result = result && this.commitLog.load();

            // load Consume Queue
            result = result && this.loadConsumeQueue();

            if (result) {
                this.storeCheckpoint =
                        new StoreCheckpoint(StorePathConfigHelper.getStoreCheckpoint(this.messageStoreConfig.getStorePathRootDir()));

                this.indexService.load(lastExitOK);

                // 尝试恢复数据
                this.recover(lastExitOK);

                log.info("load over, and the max phy offset = {}", this.getMaxPhyOffset());
            }
        } catch (Exception e) {
            log.error("load exception", e);
            result = false;
        }

        if (!result) {
            this.allocateMapedFileService.shutdown();
        }

        return result;
    }

 

新开了一篇来写:http://www.cnblogs.com/guazi/p/6836112.html

 

相关文章:

  • 2021-11-17
  • 2022-12-23
  • 2021-08-09
  • 2021-06-10
  • 2021-11-23
  • 2021-11-17
  • 2021-11-18
  • 2021-06-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2022-01-28
相关资源
相似解决方案