标签:如何 false 图片 com error class mamicode code files
考虑转发任务未成功执行,此时消息服务器Broker宕机,导致commitlog,consumeQueue,IndexFile文件数据不一致。
看一下mq关于存储文件的加载流程:
public boolean load() { boolean result = true; try { boolean lastExitOK = !this.isTempFileExist(); log.info("last shutdown {}", lastExitOK ? "normally" : "abnormally"); 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.allocateMappedFileService.shutdown(); } return result; }
判断上一次退出是否正常,broker在启动时创建abort文件,在退出时通过注册jvm钩子函数删除abort文件。如果下一次启动时存在abort文件。说明Broker是异常退出的。
标签:如何 false 图片 com error class mamicode code files
原文地址:https://www.cnblogs.com/lccsblog/p/12235321.html