RocketMQ之broker读取本地文件数据
这个load操作发生在启动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