{"id":2947,"date":"2021-06-27T22:48:31","date_gmt":"2021-06-27T14:48:31","guid":{"rendered":"\/?p=2947"},"modified":"2021-07-01T22:48:59","modified_gmt":"2021-07-01T14:48:59","slug":"5-2-%e6%b6%88%e6%81%af%e5%ad%98%e5%82%a8%e6%b5%81%e7%a8%8b%e6%a6%82%e8%a7%88","status":"publish","type":"post","link":"http:\/\/xinblog.ltd\/?p=2947","title":{"rendered":"5.2 \u6d88\u606f\u5b58\u50a8\u6d41\u7a0b\u6982\u89c8"},"content":{"rendered":"<p>\u8fd9\u6b21\u6211\u4eec\u5148\u6574\u4f53\u68b3\u7406\u4e0b\u6d88\u606f\u5b58\u50a8\u6d41\u7a0b<\/p>\n<p>\u6d88\u606f\u5b58\u50a8\u5b9e\u73b0\u7c7b\u662f org.apache.rocketmq.store.DefaultMessageStore<\/p>\n<p>\u662f\u6838\u5fc3\u7c7b\u5e93,\u5b58\u50a8\u4e86\u5927\u91cf\u7684\u5bf9\u5176\u4ed6\u6587\u4ef6\u64cd\u4f5c\u7684api<\/p>\n<p>\u6838\u5fc3\u5c5e\u6027\u5305\u62ec:<\/p>\n<p>1.MessageStoreConfig messageStoreConfig \u6d88\u606f\u5b58\u50a8\u914d\u7f6e\u5c5e\u6027<\/p>\n<p>2.CommitLog commitLog\u6587\u4ef6\u7684\u5b9e\u73b0\u7c7b<\/p>\n<p>3.ConcurrentMap&lt;String,ConcurrentMap&lt;Integer,ConsumeQueue&gt;&gt; consumeQueueTable \u6d88\u606f\u961f\u5217\u5b58\u50a8\u7f13\u5b58\u8868,\u6309\u7167\u6d88\u606f\u4e3b\u9898\u5206\u7ec4<\/p>\n<p>4.FlushConsumeQueueService \u5237\u76d8\u7ebf\u7a0b<\/p>\n<p>5.CleanCommitLogService \u6e05\u9664CommitLog\u6587\u4ef6\u670d\u52a1<\/p>\n<p>6.CleanCommitQueueService \u6e05\u9664ConsumeQueue\u6587\u4ef6\u670d\u52a1<\/p>\n<p>7.IndexService \u7d22\u5f15\u6587\u4ef6\u5b9e\u73b0\u7c7b<\/p>\n<p>8.AllocateMappendFileService MappendFile\u5206\u914d\u670d\u52a1<\/p>\n<p>9.ReputMessageService \u6d88\u606f\u5206\u53d1,\u6839\u636eCommitLog\u6784\u5efa\u5bf9\u5e94\u7684ConsumeQueue,IndexFile\u6587\u4ef6<\/p>\n<p>10.HAService \u5b58\u50a8HA\u673a\u5236<\/p>\n<p>11.MessageArrivingListener, \u6d88\u606f\u62c9\u53bb\u957f\u8f6e\u8be2\u6a21\u5f0f\u8fbe\u5230\u76d1\u542c\u5668<\/p>\n<p>12.BrokerConfig brokerConfig\u7684\u914d\u7f6e<\/p>\n<p>13.StoreCheckpoint \u6587\u4ef6\u5237\u76d8\u68c0\u6d4b\u70b9<\/p>\n<p>14.LinkedList dispatcherList \u8f6c\u53d1\u8bf7\u6c42\u5217\u8868<\/p>\n<p>\u6574\u4f53\u6d41\u7a0b\u4e3a<\/p>\n<p>\u6574\u4f53\u6d88\u606f\u5b58\u50a8\u7684\u5165\u53e3\u4e3aDefaultMessageStore#putMessage,\u6211\u4eec\u4e5f\u662f\u62ff\u7740\u540c\u6b65\u5b58\u50a8\u8fdb\u884c\u4e3e\u4f8b\u7684<\/p>\n<p>\u51fd\u6570\u4e2d,\u9996\u5148\u8fdb\u884c\u6821\u9a8c<\/p>\n<table>\n<tbody>\n<tr>\n<td>private PutMessageStatus checkStoreStatus() {<\/p>\n<p>\/\/\u5982\u679c\u5df2\u7ecf\u5173\u95ed\u4e86<\/p>\n<p>if (this.shutdown) {<\/p>\n<p><em>log<\/em>.warn(&#8220;message store has shutdown, so putMessage is forbidden&#8221;);<\/p>\n<p>return PutMessageStatus.<em>SERVICE_NOT_AVAILABLE<\/em>;<\/p>\n<p>}<\/p>\n<p>\/\/\u5982\u679c\u4e3aSlave\u89d2\u8272<\/p>\n<p>if (BrokerRole.<em>SLAVE <\/em>== this.messageStoreConfig.getBrokerRole()) {<\/p>\n<p>long value = this.printTimes.getAndIncrement();<\/p>\n<p>if ((value % 50000) == 0) {<\/p>\n<p><em>log<\/em>.warn(&#8220;broke role is slave, so putMessage is forbidden&#8221;);<\/p>\n<p>}<\/p>\n<p>return PutMessageStatus.<em>SERVICE_NOT_AVAILABLE<\/em>;<\/p>\n<p>}<\/p>\n<p>\/\/\u5982\u679c\u4e0d\u652f\u6301\u5199\u5165<\/p>\n<p>if (!this.runningFlags.isWriteable()) {<\/p>\n<p>long value = this.printTimes.getAndIncrement();<\/p>\n<p>if ((value % 50000) == 0) {<\/p>\n<p><em>log<\/em>.warn(&#8220;the message store is not writable. It may be caused by one of the following reasons: &#8221; +<\/p>\n<p>&#8220;the broker&#8217;s disk is full, write to logic queue error, write to index file error, etc&#8221;);<\/p>\n<p>}<\/p>\n<p>return PutMessageStatus.<em>SERVICE_NOT_AVAILABLE<\/em>;<\/p>\n<p>} else {<\/p>\n<p>this.printTimes.set(0);<\/p>\n<p>}<\/p>\n<p>if (this.isOSPageCacheBusy()) {<\/p>\n<p>return PutMessageStatus.<em>OS_PAGECACHE_BUSY<\/em>;<\/p>\n<p>}<\/p>\n<p>return PutMessageStatus.<em>PUT_OK<\/em>;<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7136\u540e\u662f\u68c0\u6d4b\u6d88\u606f\u672c\u8eab\u662f\u5426\u7b26\u5408\u957f\u5ea6\u76f8\u5173<\/p>\n<table>\n<tbody>\n<tr>\n<td>private PutMessageStatus checkMessage(MessageExtBrokerInner msg) {<\/p>\n<p>\/\/\u5982\u679ctopic\u540d\u5b57\u5927\u4e8e127<\/p>\n<p>if (msg.getTopic().length() &gt; Byte.<em>MAX_VALUE<\/em>) {<\/p>\n<p><em>log<\/em>.warn(&#8220;putMessage message topic length too long &#8221; + msg.getTopic().length());<\/p>\n<p>return PutMessageStatus.<em>MESSAGE_ILLEGAL<\/em>;<\/p>\n<p>}<\/p>\n<p>\/\/\u5982\u679c\u5c5e\u6027\u503c\u5927\u4e8e32767\u4e2a\u5b57\u7b26<\/p>\n<p>if (msg.getPropertiesString() != null &amp;&amp; msg.getPropertiesString().length() &gt; Short.<em>MAX_VALUE<\/em>) {<\/p>\n<p><em>log<\/em>.warn(&#8220;putMessage message properties length too long &#8221; + msg.getPropertiesString().length());<\/p>\n<p>return PutMessageStatus.<em>MESSAGE_ILLEGAL<\/em>;<\/p>\n<p>}<\/p>\n<p>return PutMessageStatus.<em>PUT_OK<\/em>;<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7136\u540e\u8fdb\u5165commitLog#putMessage\u4e2d<\/p>\n<table>\n<tbody>\n<tr>\n<td>\/\/ Set the storage time<\/p>\n<p>msg.setStoreTimestamp(System.<em>currentTimeMillis<\/em>());<\/p>\n<p>\/\/ Set the message body BODY CRC (consider the most appropriate setting<\/p>\n<p>\/\/ on the client)<\/p>\n<p>\/\/\u5b58\u5165\u73b0\u5728\u7684\u6821\u9a8c\u503c,\u65b9\u4fbf\u540e\u7eed\u7684\u8ba1\u7b97,\u8fdb\u884c\u4e00\u81f4\u6027\u7684\u6bd4\u8f83,\u4f7f\u7528\u7684\u662f\u5e38\u7528\u7684crc\u6821\u9a8c\u65b9\u5f0f<\/p>\n<p>msg.setBodyCRC(UtilAll.<em>crc32<\/em>(msg.getBody()));<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7136\u540e\u6211\u4eec\u83b7\u53d6\u5230\u662f\u4e0d\u662f\u5ef6\u8fdf\u6d88\u606f<\/p>\n<p>\u5982\u679c\u662fDelayTimeLevel\u5927\u4e8e0\u7684\u8bdd,\u90a3\u4e48\u73b0\u5c06topic\u8bbe\u7f6e\u4e3a\u5ef6\u8fdf\u6d88\u606f\u4e3b\u9898<\/p>\n<p>\/\/\u8bbe\u7f6etopic\u4e3a\u5ef6\u8fdf\u6d88\u606f\u4e3b\u9898<\/p>\n<p>topic = TopicValidator.RMQ_SYS_SCHEDULE_TOPIC;<\/p>\n<p>\u7136\u540e\u5c06\u539f\u672c\u7684\u6d88\u606f\u961f\u5217\u5b58\u50a8\u8d77\u6765<\/p>\n<p>MessageAccessor.putProperty(msg, MessageConst.PROPERTY_REAL_TOPIC, msg.getTopic());<\/p>\n<p>MessageAccessor.putProperty(msg, MessageConst.PROPERTY_REAL_QUEUE_ID, String.valueOf(msg.getQueueId()));<\/p>\n<p>msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties()));<\/p>\n<p>\u83b7\u53d6\u5230\u53ef\u4ee5\u5199\u5165\u7684CommitLog\u6587\u4ef6,\u4ecemappendFileQueue\u4e2d\u83b7\u53d6,\u672c\u8d28\u4e0a\u5c31\u662f\u5bf9\u5e94\u7684\u6587\u4ef6<\/p>\n<p>MappedFile mappedFile = this.mappedFileQueue.getLastMappedFile();<\/p>\n<table>\n<tbody>\n<tr>\n<td>public MappedFile getLastMappedFile() {<\/p>\n<p>MappedFile mappedFileLast = null;<\/p>\n<p>while (!this.mappedFiles.isEmpty()) {<\/p>\n<p>try {<\/p>\n<p>mappedFileLast = this.mappedFiles.get(this.mappedFiles.size() &#8211; 1);<\/p>\n<p>break;<\/p>\n<p>} catch (IndexOutOfBoundsException e) {<\/p>\n<p>\/\/continue;<\/p>\n<p>} catch (Exception e) {<\/p>\n<p><em>log<\/em>.error(&#8220;getLastMappedFile has exception.&#8221;, e);<\/p>\n<p>break;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>return mappedFileLast;<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5728\u8fd9\u4e00\u6bb5\u4e2d,\u83b7\u53d6\u5230\u6700\u540e\u4e00\u4e2a\u53ef\u4ee5\u5199\u5165\u7684commitLog<\/p>\n<p>\u8fd9\u6837\u83b7\u53d6\u7684\u539f\u7406\u5728\u4e8e<\/p>\n<p>commitlog\u76ee\u5f55\u4e2d,\u6bcf\u4e00\u4e2a\u6587\u4ef6\u9ed8\u8ba4\u5927\u5c0f\u4e3a1G,\u4ee5\u6587\u4ef6\u7684\u7b2c\u4e00\u4e2a\u504f\u79fb\u91cf\u4e3a\u6587\u4ef6\u540d,\u4e0d\u8db3\u7684\u4ee50\u5bf9\u5176,\u7b2c\u4e00\u4e2a\u6587\u4ef6\u7684\u6587\u4ef6\u540d\u4e3a0,\u7b2c\u4e8c\u4e2a\u6587\u4ef6\u540d\u4e3a1073741824,\u4e5f\u662f\u65b9\u4fbf\u5feb\u901f\u7684\u901a\u8fc7\u6587\u4ef6\u504f\u79fb\u91cf\u83b7\u53d6\u5230\u5bf9\u5e94\u7684\u6d88\u606f<\/p>\n<p>\u7ee7\u7eed\u8d70\u4e3b\u6d41\u7a0b<\/p>\n<p>\u5199\u5165\u4e4b\u524d,\u7533\u8bf7putMessageLock,\u800c\u4e14\u662f\u963b\u585e\u5f0f\u7684\u83b7\u53d6\u9501<\/p>\n<p>\u7136\u540e\u68c0\u6d4b\u5e76\u5c1d\u8bd5\u521b\u5efamappendFile<\/p>\n<table>\n<tbody>\n<tr>\n<td>\/\/\u4e3a\u7a7a,\u6216\u8005\u6ee1\u4e86<\/p>\n<p>if (null == mappedFile || mappedFile.isFull()) {<\/p>\n<p>\/\/\u76f4\u63a5\u53bb\u521b\u5efa\u7b2c\u4e00\u4e2a\u6587\u4ef6<\/p>\n<p>mappedFile = this.mappedFileQueue.getLastMappedFile(0); \/\/ Mark: NewFile may be cause noise<\/p>\n<p>}<\/p>\n<p>\/\/\u8fd8\u662f\u4e3a\u7a7a,\u8bf4\u660e\u662f\u521b\u5efa\u5931\u8d25,\u629b\u51faCREATE MAPEDFILE FAILED \u78c1\u76d8\u4e0d\u591f\u6216\u8005\u6743\u9650\u4e0d\u8db3<\/p>\n<p>if (null == mappedFile) {<\/p>\n<p><em>log<\/em>.error(&#8220;create mapped file1 error, topic: &#8221; + msg.getTopic() + &#8221; clientAddr: &#8221; + msg.getBornHostString());<\/p>\n<p>beginTimeInLock = 0;<\/p>\n<p>return new PutMessageResult(PutMessageStatus.<em>CREATE_MAPEDFILE_FAILED<\/em>, null);<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u63a5\u4e0b\u6765,MappendFile\u5df2\u7ecf\u521b\u5efa\u51fa\u6765\u4e86,\u90a3\u4e48\u8ffd\u52a0\u5230mappendFile\u4e2d<\/p>\n<p>\u8d70MappendFile\u7684appendMessagesInner\u51fd\u6570<\/p>\n<table>\n<tbody>\n<tr>\n<td>\/\/\u83b7\u53d6\u5230\u5199\u6307\u9488<\/p>\n<p>int currentPos = this.wrotePosition.get();<\/p>\n<p>if (currentPos &lt; this.fileSize) {<\/p>\n<p>\/\/&#8230;&#8230;<\/p>\n<p>}<\/p>\n<p>\/\/ \u8d70\u5230\u8fd9\u4e00\u6b65,\u8bf4\u660e\u6587\u4ef6\u5df2\u7ecf\u5199\u6ee1\u4e86,\u629b\u51fa\u4e00\u4e2aAppendMessageStatus.UNKOWN_ERRPR<\/p>\n<p><em>log<\/em>.error(&#8220;MappedFile.appendMessage return null, wrotePosition: {} fileSize: {}&#8221;, currentPos, this.fileSize);<\/p>\n<p>return new AppendMessageResult(AppendMessageStatus.<em>UNKNOWN_ERROR<\/em>);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u6587\u4ef6\u5199\u6ee1\u4e86,\u90a3\u4e48\u5c31\u4f1a\u629b\u51fa\u4e00\u4e2aAppendMessageStatus.UNKOWN_ERROR<\/p>\n<p>\u5982\u679c\u5c0f\u4e8e\u7684\u8bdd,\u90a3\u4e48<\/p>\n<p>\u5148\u5229\u7528slice\u83b7\u53d6\u5230\u4e00\u4e2aByteBuffer<\/p>\n<p>ByteBuffer byteBuffer = writeBuffer != null ? writeBuffer.slice() : this.mappedByteBuffer.slice();<\/p>\n<p>\u8bbe\u7f6e\u5bf9\u5e94\u7684position\u4e3a\u5f53\u524d\u6307\u9488<\/p>\n<p>\u7136\u540e\u8d70\u4e0b\u4e00\u6b65\u64cd\u4f5c,\u8fdb\u884c\u6dfb\u52a0,\u751f\u6210result\u8fd4\u56de<\/p>\n<p>\u8d70\u5230doAppend\u51fd\u6570\u4e2d<\/p>\n<p>\u8fdb\u884c\u4e00\u4e9b\u9884\u70ed\u7684\u64cd\u4f5c<\/p>\n<p>\u9996\u5148\u662f\u52a0\u4e0a\u5bf9\u5e94\u7684\u6587\u4ef6\u5927\u5c0f,\u7136\u540e\u521b\u5efa\u5168\u5c40\u552f\u4e00\u7684\u6d88\u606fId,<\/p>\n<p>\u7531 4\u5b57\u8282\u7684IP 4\u5b57\u8282\u7684\u7aef\u53e3\u53f7 \u4ee5\u53ca8\u5b57\u8282\u7684\u6d88\u606f\u504f\u79fb\u91cf\u6784\u6210<\/p>\n<p>\u7136\u540e\u83b7\u53d6\u5230\u5bf9\u5e94\u7684\u504f\u79fb\u91cf,\u5e76\u5c1d\u8bd5\u5199\u5165<\/p>\n<p>\u8ba1\u7b97\u6d88\u606f\u7684\u603b\u957f\u5ea6,\u83b7\u53d6\u5230\u5c5e\u6027\u957f\u5ea6,\u83b7\u53d6\u5230\u5230topic\u957f\u5ea6,\u6d88\u606f\u4f53\u957f\u5ea6<\/p>\n<p>\u5728calMsgLength\u4e2d,\u8fdb\u884c\u8ba1\u7b97\u6d88\u606f\u4f53\u957f\u5ea6<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"833\" height=\"528\" class=\"wp-image-2948\" src=\"\/wp-content\/uploads\/2021\/07\/unnamed-file-1.png\" alt=\"\u56fe\u7247\" srcset=\"http:\/\/xinblog.ltd\/wp-content\/uploads\/2021\/07\/unnamed-file-1.png 833w, http:\/\/xinblog.ltd\/wp-content\/uploads\/2021\/07\/unnamed-file-1-300x190.png 300w, http:\/\/xinblog.ltd\/wp-content\/uploads\/2021\/07\/unnamed-file-1-768x487.png 768w\" sizes=\"(max-width: 833px) 100vw, 833px\" \/><\/p>\n<p>\u6839\u636e\u5b9a\u957f\u7684\u548c\u4e0d\u5b9a\u957f\u7684\u7ec4\u6210\u5bf9\u5e94\u7684\u6d88\u606f\u4f53\u957f\u5ea6,\u603b\u5171\u5927\u5c0f\u4e0d\u4f1a\u8d85\u8fc74\u4e2a\u5b57\u8282<\/p>\n<p>\u83b7\u53d6\u5230\u4e86\u6d88\u606f\u957f\u5ea6\u4e4b\u540e,\u6211\u4eec\u8fdb\u884c\u6bd4\u5bf9<\/p>\n<p>\u5982\u679c\u957f\u5ea6\u5927\u4e8e\u4e86\u6700\u5927\u7684\u6d88\u606f\u957f\u5ea6,\u62a5\u9519<\/p>\n<p>\u5982\u679c\u6d88\u606f\u4f53\u957f\u5ea6\u52a0\u4e0a\u5f53\u524d\u957f\u5ea6\u5927\u4e8e\u4e86\u6587\u4ef6\u7684\u6700\u5927\u957f\u5ea6,\u90a3\u4e48\u4f1a\u8003\u8651\u521b\u5efa\u4e00\u4e2a\u65b0\u7684commitLog\u6587\u4ef6\u6765\u8fdb\u884c\u5b58\u50a8<\/p>\n<p>\u63a5\u4e0b\u6765\u8fdb\u884c\u5b9e\u9645\u7684\u5b58\u5165<\/p>\n<p>\u4e00\u6b65\u6b65\u7684\u5b58\u5165\u5b9e\u9645\u7684\u503c,\u8bf8\u5982msgLen,\u6d88\u606f\u4f53,topic\u7b49<\/p>\n<p>\u751f\u6210\u8fd4\u56de\u503c\u8fdb\u884c\u8fd4\u56de<\/p>\n<table>\n<tbody>\n<tr>\n<td>\/\/ Initialization of storage space<\/p>\n<p>this.resetByteBuffer(msgStoreItemMemory, msgLen);<\/p>\n<p>\/\/ 1 TOTALSIZE<\/p>\n<p>this.msgStoreItemMemory.putInt(msgLen);<\/p>\n<p>\/\/ 2 MAGICCODE<\/p>\n<p>this.msgStoreItemMemory.putInt(CommitLog.<em>MESSAGE_MAGIC_CODE<\/em>);<\/p>\n<p>\/\/ 3 BODYCRC<\/p>\n<p>this.msgStoreItemMemory.putInt(msgInner.getBodyCRC());<\/p>\n<p>\/\/ 4 QUEUEID<\/p>\n<p>this.msgStoreItemMemory.putInt(msgInner.getQueueId());<\/p>\n<p>\/\/ 5 FLAG<\/p>\n<p>this.msgStoreItemMemory.putInt(msgInner.getFlag());<\/p>\n<p>\/\/ 6 QUEUEOFFSET<\/p>\n<p>this.msgStoreItemMemory.putLong(queueOffset);<\/p>\n<p>\/\/ 7 PHYSICALOFFSET<\/p>\n<p>this.msgStoreItemMemory.putLong(fileFromOffset + byteBuffer.position());<\/p>\n<p>\/\/ 8 SYSFLAG<\/p>\n<p>this.msgStoreItemMemory.putInt(msgInner.getSysFlag());<\/p>\n<p>\/\/ 9 BORNTIMESTAMP<\/p>\n<p>this.msgStoreItemMemory.putLong(msgInner.getBornTimestamp());<\/p>\n<p>\/\/ 10 BORNHOST<\/p>\n<p>this.resetByteBuffer(bornHostHolder, bornHostLength);<\/p>\n<p>this.msgStoreItemMemory.put(msgInner.getBornHostBytes(bornHostHolder));<\/p>\n<p>\/\/ 11 STORETIMESTAMP<\/p>\n<p>this.msgStoreItemMemory.putLong(msgInner.getStoreTimestamp());<\/p>\n<p>\/\/ 12 STOREHOSTADDRESS<\/p>\n<p>this.resetByteBuffer(storeHostHolder, storeHostLength);<\/p>\n<p>this.msgStoreItemMemory.put(msgInner.getStoreHostBytes(storeHostHolder));<\/p>\n<p>\/\/ 13 RECONSUMETIMES<\/p>\n<p>this.msgStoreItemMemory.putInt(msgInner.getReconsumeTimes());<\/p>\n<p>\/\/ 14 Prepared Transaction Offset<\/p>\n<p>this.msgStoreItemMemory.putLong(msgInner.getPreparedTransactionOffset());<\/p>\n<p>\/\/ 15 BODY<\/p>\n<p>this.msgStoreItemMemory.putInt(bodyLength);<\/p>\n<p>if (bodyLength &gt; 0)<\/p>\n<p>this.msgStoreItemMemory.put(msgInner.getBody());<\/p>\n<p>\/\/ 16 TOPIC<\/p>\n<p>this.msgStoreItemMemory.put((byte) topicLength);<\/p>\n<p>this.msgStoreItemMemory.put(topicData);<\/p>\n<p>\/\/ 17 PROPERTIES<\/p>\n<p>this.msgStoreItemMemory.putShort((short) propertiesLength);<\/p>\n<p>if (propertiesLength &gt; 0)<\/p>\n<p>this.msgStoreItemMemory.put(propertiesData);<\/p>\n<p>final long beginTimeMills = CommitLog.this.defaultMessageStore.now();<\/p>\n<p>\/\/ Write messages to the queue buffer<\/p>\n<p>byteBuffer.put(this.msgStoreItemMemory.array(), 0, msgLen);<\/p>\n<p>\/\/\u751f\u6210\u8fd4\u56de\u503c<\/p>\n<p>AppendMessageResult result = new AppendMessageResult(AppendMessageStatus.<em>PUT_OK<\/em>, wroteOffset, msgLen, msgId,<\/p>\n<p>msgInner.getStoreTimestamp(), queueOffset, CommitLog.this.defaultMessageStore.now() &#8211; beginTimeMills);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f46\u662f\u8fd9\u65f6\u5019,\u53ea\u662f\u5c06\u5185\u5bb9\u5b58\u5728\u4e86ByteBuffer\u4e2d,\u5e76\u6ca1\u6709\u8f93\u76d8<\/p>\n<p>\u662f\u7684\u8fd9\u91cc\u9762\u8fd8\u6709buffer\u7684\u5237\u76d8\u8fc7\u7a0b<\/p>\n<p>\u90a3\u4e48\u5728\u6700\u540e,\u6211\u4eec\u8bf4\u4e00\u4e0borg.apache.rocketmq.store.AppendMessageResult<\/p>\n<p>\u5185\u90e8\u542b\u6709\u7684\u5c5e\u6027\u5982\u4e0b<\/p>\n<p>AppendMessageStatus \u6d88\u606f\u7ed3\u679c,\u8ffd\u52a0\u6210\u529f\u5c31\u662fPUT_OK<\/p>\n<p>long wroteOffset \u6d88\u606f\u7684\u7269\u7406\u504f\u79fb\u91cf<\/p>\n<p>String msgId \u6d88\u606fId<\/p>\n<p>long storeTimestamp\u6d88\u606f\u65f6\u95f4\u6233<\/p>\n<p>int msgNum = 1 \u6d88\u606f\u6761\u6570,\u6279\u91cf\u6d88\u606f\u53d1\u9001\u7684\u65f6\u5019\u6d88\u606f\u6761\u6570<\/p>\n<p>\u90a3\u4e48\u5230\u8fd9\u91cc,\u5c31\u57fa\u672c\u8fd4\u56de\u51fd\u6570\u4e86<\/p>\n<p>\u522b\u5fd8\u4e86\u89e3\u9501\u7684\u64cd\u4f5c<\/p>\n<p>\u7136\u540e\u751f\u6210\u8fd4\u56de\u4e22\u5411<\/p>\n<p>\u8fdb\u884c\u771f\u6b63\u7684\u5237\u76d8\u5de5\u4f5c<\/p>\n<p>handleDiskFlush(result,putMessageResult,msg)<\/p>\n<p>\u8f93\u76d8\u5b8c\u6210\u4e4b\u540e\u6267\u884cHA\u4e3b\u4ece\u540c\u6b65\u590d\u5236<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u6b21\u6211\u4eec\u5148\u6574\u4f53\u68b3\u7406\u4e0b\u6d88\u606f\u5b58\u50a8\u6d41 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"_links":{"self":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/posts\/2947"}],"collection":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2947"}],"version-history":[{"count":0,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/posts\/2947\/revisions"}],"wp:attachment":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2947"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2947"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}