{"id":96098,"date":"2026-08-27T13:32:47","date_gmt":"2026-08-27T05:32:47","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/96098.html"},"modified":"2026-08-27T13:32:47","modified_gmt":"2026-08-27T05:32:47","slug":"rocketmq%e9%a1%ba%e5%ba%8f%e6%b6%88%e8%b4%b9%e7%9a%84%e5%8a%a0%e9%94%81%e6%9c%ba%e5%88%b6","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/96098.html","title":{"rendered":"RocketMQ\u987a\u5e8f\u6d88\u8d39\u7684\u52a0\u9501\u673a\u5236"},"content":{"rendered":"<p>\u6709\u5f00\u53d1\u8005\u5728\u4f7f\u7528RocketMQ\u7684MessageListenerOrderly\u505a\u987a\u5e8f\u6d88\u8d39\u65f6&#xff0c;\u53d1\u73b0\u65e5\u5fd7\u91cc\u540c\u4e00\u4e2a\u7ebf\u7a0b\u5728\u540c\u4e00\u6beb\u79d2\u5185\u8fde\u7eed\u6253\u5370\u4e86\u591a\u6761\u6d88\u606f&#xff1a;<\/p>\n<p>[ConsumeMessageThread_10] msg is :Hello RocketMQ 75<br \/>\n[ConsumeMessageThread_10] msg is :Hello RocketMQ 79<br \/>\n[ConsumeMessageThread_10] msg is :Hello RocketMQ 83<br \/>\n[ConsumeMessageThread_10] msg is :Hello RocketMQ 87<br \/>\n[ConsumeMessageThread_10] msg is :Hello RocketMQ 91<br \/>\n[ConsumeMessageThread_10] msg is :Hello RocketMQ 95<br \/>\n[ConsumeMessageThread_10] msg is :Hello RocketMQ 99<\/p>\n<p>\u6d88\u606f\u7f16\u53f775\u300179\u300183\u202699&#xff0c;\u9012\u589e\u987a\u5e8f\u6ca1\u95ee\u9898&#xff0c;\u4f46\u540c\u4e00\u4e2a\u7ebf\u7a0b\u4e00\u53e3\u6c14\u6d88\u8d39\u4e867\u6761&#xff0c;\u770b\u8d77\u6765\u5e76\u4e0d\u50cf\u300c\u53d6\u4e00\u6761\u3001\u9501\u4f4f\u3001\u6d88\u8d39\u5b8c\u3001\u89e3\u9501\u3001\u518d\u53d6\u4e0b\u4e00\u6761\u300d\u7684\u6a21\u5f0f\u3002\u63d0\u95ee\u8005\u6000\u7591\u8fd9\u4e0d\u7b97\u771f\u6b63\u7684\u987a\u5e8f\u6d88\u8d39&#xff0c;\u89c9\u5f97\u5ba2\u6237\u7aef\u5728\u6ca1\u6709commit\u7684\u60c5\u51b5\u4e0b&#xff0c;\u4f1a\u7ee7\u7eed\u4ece\u961f\u5217\u62ff\u6570\u636e\u653e\u5230\u7ebf\u7a0b\u6c60\u91cc\u5e76\u53d1\u6d88\u8d39\u3002<\/p>\n<p>\u4eceRocketMQ 4.9.8\u7684\u6e90\u7801\u6765\u770b&#xff0c;\u987a\u5e8f\u6d88\u8d39\u7684\u4fdd\u8bc1\u662f\u771f\u5b9e\u7684\u3002\u540c\u4e00\u4e2a\u7ebf\u7a0b\u8fde\u7eed\u6d88\u8d39\u591a\u6761\u6d88\u606f&#xff0c;\u4e0d\u662f\u5e76\u53d1&#xff0c;\u800c\u662fwhile\u5faa\u73af\u5728\u540c\u4e00\u628a\u9501\u5185\u9010\u6761\u5904\u7406\u3002\u4e0b\u9762\u4ece\u6e90\u7801\u89d2\u5ea6\u5c1d\u8bd5\u68b3\u7406\u4e00\u4e0b\u8fd9\u4e2a\u52a0\u9501\u673a\u5236\u3002<\/p>\n<h3>\u987a\u5e8f\u6d88\u8d39\u7684\u4e24\u5c42\u4fdd\u62a4<\/h3>\n<p>\u987a\u5e8f\u6d88\u8d39\u8981\u89e3\u51b3\u4e00\u4e2a\u95ee\u9898&#xff1a;\u540c\u4e00\u4e2a\u961f\u5217\u7684\u6d88\u606f\u5fc5\u987b\u6309\u987a\u5e8f\u4e00\u6761\u4e00\u6761\u5904\u7406&#xff0c;\u4e0d\u80fd\u6709\u4e24\u4e2a\u7ebf\u7a0b\u540c\u65f6\u6d88\u8d39\u540c\u4e00\u4e2a\u961f\u5217\u3002RocketMQ\u5728\u5ba2\u6237\u7aef\u7528\u4e86\u4e24\u5c42\u673a\u5236\u6765\u4fdd\u8bc1\u8fd9\u4e00\u70b9\u3002<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827053244-6a8fcbfc62a4d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7b2c\u4e00\u5c42\u662fProcessQueue\u91cc\u7684consuming\u6807\u5fd7\u3002Pull\u7ebf\u7a0b\u4eceBroker\u62c9\u56de\u6d88\u606f\u540e&#xff0c;\u8c03\u7528ProcessQueue\u7684putMessage\u65b9\u6cd5\u628a\u6d88\u606f\u5b58\u5165\u5185\u90e8\u7684TreeMap\u3002putMessage\u5b58\u5b8c\u6d88\u606f\u540e\u4f1a\u68c0\u67e5&#xff1a;\u5982\u679c\u5f53\u524d\u6ca1\u6709\u6d88\u8d39\u4efb\u52a1\u5728\u8dd1&#xff08;consuming\u4e3afalse&#xff09;&#xff0c;\u5c31\u628aconsuming\u7f6e\u4e3atrue&#xff0c;\u8fd4\u56de\u4e00\u4e2a\u6807\u8bb0\u8ba9\u4e0a\u5c42\u63d0\u4ea4\u4e00\u4e2a\u65b0\u7684\u6d88\u8d39\u4efb\u52a1\u5230\u7ebf\u7a0b\u6c60\u3002\u5982\u679cconsuming\u5df2\u7ecf\u662ftrue&#xff0c;\u8bf4\u660e\u8fd9\u4e2a\u961f\u5217\u5df2\u7ecf\u6709\u6d88\u8d39\u4efb\u52a1\u5728\u8dd1\u4e86&#xff0c;putMessage\u8fd4\u56defalse&#xff0c;\u4e0a\u5c42\u5c31\u4e0d\u4f1a\u91cd\u590d\u63d0\u4ea4\u3002<\/p>\n<p>\u8fd9\u4e00\u5c42\u8981\u8fbe\u5230\u7684\u76ee\u7684\u662f&#xff1a;<\/p>\n<p>\u540c\u4e00\u4e2a\u961f\u5217&#xff0c;\u540c\u4e00\u65f6\u523b\u53ea\u6709\u4e00\u4e2a\u6d88\u8d39\u4efb\u52a1\u5728\u8dd1\u3002\u540e\u7eedPull\u62c9\u5230\u7684\u65b0\u6d88\u606f\u53ea\u662f\u653e\u8fdbTreeMap\u91cc\u7b49\u7740&#xff0c;\u4e0d\u4f1a\u89e6\u53d1\u65b0\u7684\u6d88\u8d39\u4efb\u52a1\u63d0\u4ea4\u3002<\/p>\n<p>\u7b2c\u4e8c\u5c42\u662fMessageQueueLock\u4e3a\u6bcf\u4e2a\u6d88\u606f\u961f\u5217\u5206\u914d\u7684\u72ec\u7acb\u9501\u3002ConsumeMessageOrderlyService\u5185\u90e8\u7ef4\u62a4\u4e86\u4e00\u4e2aMessageQueueLock&#xff0c;\u5b83\u7528\u4e00\u4e2aConcurrentHashMap\u4e3a\u6bcf\u4e2a\u6d88\u606f\u961f\u5217\u5206\u914d\u4e00\u4e2a\u72ec\u7acb\u7684Object\u9501\u3002\u6d88\u8d39\u4efb\u52a1\u6267\u884c\u65f6&#xff0c;\u7b2c\u4e00\u6b65\u5c31\u662f\u62ff\u5230\u8fd9\u4e2a\u961f\u5217\u5bf9\u5e94\u7684\u9501\u5bf9\u8c61&#xff0c;\u7136\u540e\u8fdb\u5165synchronized\u5757\u3002<\/p>\n<p>\u8fd9\u4e00\u5c42\u662f\u515c\u5e95\u3002\u5373\u4f7f\u56e0\u4e3a\u67d0\u4e9b\u6781\u7aef\u60c5\u51b5\u5bfc\u81f4\u4e24\u4e2a\u6d88\u8d39\u4efb\u52a1\u540c\u65f6\u5b58\u5728&#xff0c;\u5b83\u4eec\u4e5f\u4f1a\u5728synchronized\u4e0a\u6392\u961f&#xff0c;\u540c\u4e00\u65f6\u523b\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u80fd\u8fdb\u5165\u6d88\u8d39\u903b\u8f91\u3002<\/p>\n<h3>while\u5faa\u73af&#xff1a;\u9501\u4f4f\u961f\u5217\u8fde\u7eed\u6d88\u8d39<\/h3>\n<p>\u8fdb\u5165synchronized\u5757\u4e4b\u540e&#xff0c;\u6d88\u8d39\u903b\u8f91\u4e0d\u662f\u6d88\u8d39\u5b8c\u4e00\u6761\u6d88\u606f\u5c31\u9000\u51fa\u91ca\u653e\u9501\u3002ConsumeRequest\u7684run\u65b9\u6cd5\u91cc\u662f\u4e00\u4e2awhile\u5faa\u73af&#xff0c;\u6bcf\u8f6e\u5faa\u73af\u505a\u4e09\u4ef6\u4e8b&#xff1a;<\/p>\n<p>1.\u4eceProcessQueue\u6309\u504f\u79fb\u91cf\u987a\u5e8f\u53d6\u51fa\u4e00\u6279\u6d88\u606f\u3002<\/p>\n<p>2.\u8c03\u7528\u6ce8\u518c\u7684\u76d1\u542c\u5668\u6267\u884c\u4e1a\u52a1\u903b\u8f91\u3002<\/p>\n<p>3.\u6839\u636e\u8fd4\u56de\u503c\u51b3\u5b9a\u662f\u7ee7\u7eed\u8fd8\u662f\u505c\u6b62\u3002<\/p>\n<p>ProcessQueue\u5185\u90e8\u7528TreeMap\u5b58\u50a8\u6d88\u606f&#xff0c;\u4ee5\u6d88\u606f\u504f\u79fb\u91cf\u4e3a\u952e&#xff0c;\u5929\u7136\u6709\u5e8f\u3002\u53d6\u6d88\u606f\u65f6\u4eceTreeMap\u5934\u90e8\u4f9d\u6b21\u53d6\u51fa\u6700\u5c0f\u7684\u51e0\u4e2a\u504f\u79fb\u91cf&#xff0c;\u4fdd\u8bc1\u4e86\u6d88\u8d39\u987a\u5e8f\u3002\u9ed8\u8ba4\u6bcf\u6b21\u53ea\u53d61\u6761&#xff08;\u7531consumeMessageBatchMaxSize\u63a7\u5236&#xff0c;\u9ed8\u8ba4\u503c\u4e3a1&#xff09;\u3002<\/p>\n<p>\u5982\u679c\u961f\u5217\u91cc\u8fd8\u6709\u6d88\u606f&#xff0c;continueConsume\u4fdd\u6301\u4e3atrue&#xff0c;\u5faa\u73af\u7ee7\u7eed\u3002\u5982\u679c\u961f\u5217\u4e3a\u7a7a&#xff0c;consuming\u6807\u5fd7\u91cd\u7f6e\u4e3afalse&#xff0c;\u5faa\u73af\u9000\u51fa&#xff0c;synchronized\u9501\u91ca\u653e\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u63d0\u95ee\u8005\u65e5\u5fd7\u91cc\u770b\u5230\u7684\u73b0\u8c61&#xff1a;\u540c\u4e00\u4e2a\u7ebf\u7a0bConsumeMessageThread_10&#xff0c;\u5728\u540c\u4e00\u6beb\u79d2\u5185\u8fde\u7eed\u6d88\u8d39\u4e86\u6d88\u606f75\u300179\u300183\u202699\u3002\u8fd9\u4e9b\u6d88\u606f\u662f\u5728\u540c\u4e00\u4e2a\u7ebf\u7a0b\u3001\u540c\u4e00\u628asynchronized\u9501\u5185\u3001\u6309\u504f\u79fb\u91cf\u9012\u589e\u987a\u5e8f\u9010\u6761\u5904\u7406\u7684\u3002\u6d88\u8d39\u5b8c75\u4e0d\u91ca\u653e\u9501&#xff0c;\u76f4\u63a5\u8fdb\u5165\u4e0b\u4e00\u8f6e\u5faa\u73af\u6d88\u8d3979&#xff0c;\u518d\u4e0b\u4e00\u8f6e\u6d88\u8d3983&#xff0c;\u4f9d\u6b64\u7c7b\u63a8&#xff0c;\u76f4\u5230\u961f\u5217\u7a7a\u4e86\u624d\u9000\u51fa\u5faa\u73af\u91ca\u653e\u9501\u3002<\/p>\n<p>\u5bb9\u6613\u88ab\u8bef\u89e3\u7684\u4e00\u70b9\u662f&#xff1a;\u88ab\u63d0\u4ea4\u5230\u7ebf\u7a0b\u6c60\u7684\u4e0d\u662f\u5355\u6761\u6d88\u606f&#xff0c;\u800c\u662f\u6574\u4e2a\u961f\u5217\u7684\u6d88\u8d39\u4efb\u52a1\u3002\u4e00\u4e2a\u6d88\u8d39\u4efb\u52a1\u5185\u90e8\u7528while\u5faa\u73af\u9010\u6761\u6d88\u8d39\u8fd9\u4e2a\u961f\u5217\u7684\u6d88\u606f\u3002\u63d0\u95ee\u8005\u7684\u65e5\u5fd7\u91cc\u770b\u5230\u540c\u4e00\u4e2a\u7ebf\u7a0b\u8fde\u7eed\u6d88\u8d39\u591a\u6761\u6d88\u606f&#xff0c;\u6070\u6070\u8bf4\u660e\u987a\u5e8f\u6d88\u8d39\u5728\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<p>\u987a\u5e8f\u6d88\u8d39\u9501\u7684\u7c92\u5ea6\u662f\u961f\u5217&#xff0c;\u4e0d\u662f\u6d88\u606f\u3002 \u9501\u4f4f\u961f\u5217\u540e&#xff0c;\u540c\u4e00\u4e2a\u7ebf\u7a0b\u5728\u5faa\u73af\u91cc\u8fde\u7eed\u6d88\u8d39\u591a\u6761&#xff0c;\u4e2d\u95f4\u4e0d\u91ca\u653e\u9501\u3002\u8fd9\u548c\u63d0\u95ee\u8005\u60f3\u8c61\u7684\u300c\u6bcf\u6761\u6d88\u606f\u5355\u72ec\u52a0\u9501\u89e3\u9501\u300d\u5728\u7ed3\u679c\u4e0a\u662f\u4e00\u6837\u7684&#xff0c;\u90fd\u4fdd\u8bc1\u4e86\u987a\u5e8f&#xff0c;\u53ea\u662f\u9501\u7684\u6301\u6709\u5468\u671f\u4e0d\u540c\u3002<\/p>\n<h3>autoCommit(false)\u4e3a\u4ec0\u4e48\u4e0d\u963b\u6b62\u5faa\u73af\u7ee7\u7eed<\/h3>\n<p>\u63d0\u95ee\u8005\u7684\u6d4b\u8bd5\u4ee3\u7801\u91cc\u505a\u4e86\u4e24\u4ef6\u4e8b&#xff1a;\u8bbe\u4e86context.setAutoCommit(false)&#xff0c;\u4ee5\u53ca\u8fd4\u56deConsumeOrderlyStatus.SUCCESS\u3002\u63d0\u95ee\u8005\u671f\u671b\u300c\u6ca1\u6709commit\u5c31\u4e0d\u7ee7\u7eed\u6d88\u8d39\u300d&#xff0c;\u4f46\u5b9e\u9645\u884c\u4e3a\u662f\u5faa\u73af\u7ee7\u7eed\u6d88\u8d39\u4e0b\u4e00\u6761\u3002<\/p>\n<p>autoCommit\u63a7\u5236\u7684\u662f\u6d88\u8d39\u4f4d\u70b9\u662f\u5426\u63d0\u4ea4\u7ed9Broker&#xff0c;\u4e0d\u5f71\u54cd\u6d88\u8d39\u5faa\u73af\u662f\u5426\u7ee7\u7eed\u3002<\/p>\n<p>\u770bConsumeMessageOrderlyService\u7684processConsumeResult\u65b9\u6cd5&#xff0c;\u5f53autoCommit\u4e3afalse\u4e14\u72b6\u6001\u4e3aSUCCESS\u65f6&#xff0c;\u53ea\u505a\u4e86TPS\u7edf\u8ba1&#xff0c;\u6ca1\u6709\u8c03\u7528commit()&#xff0c;continueConsume\u4fdd\u6301\u9ed8\u8ba4\u503ctrue\u3002\u5faa\u73af\u7167\u5e38\u7ee7\u7eed\u53d6\u4e0b\u4e00\u6761\u6d88\u606f\u3002\u800cautoCommit\u4e3atrue\u4e14\u72b6\u6001\u4e3aSUCCESS\u65f6&#xff0c;\u4f1a\u8c03\u7528ProcessQueue\u7684commit()\u65b9\u6cd5\u63d0\u4ea4\u504f\u79fb\u91cf\u3002\u4e24\u8005\u7684\u533a\u522b\u4ec5\u5728\u4e8e\u504f\u79fb\u91cf\u662f\u5426\u4e0a\u62a5\u7ed9Broker\u3002<\/p>\n<table>\n<tr>\u8fd4\u56de\u72b6\u6001autoCommit&#061;trueautoCommit&#061;false<\/tr>\n<tbody>\n<tr>\n<td>SUCCESS<\/td>\n<td>\u81ea\u52a8\u63d0\u4ea4\u504f\u79fb\u91cf&#xff0c;\u7ee7\u7eed\u4e0b\u4e00\u6761<\/td>\n<td>\u4e0d\u63d0\u4ea4\u504f\u79fb\u91cf&#xff0c;\u7ee7\u7eed\u4e0b\u4e00\u6761<\/td>\n<\/tr>\n<tr>\n<td>COMMIT<\/td>\n<td>\u63d0\u4ea4\u504f\u79fb\u91cf&#xff0c;\u7ee7\u7eed\u4e0b\u4e00\u6761<\/td>\n<td>\u63d0\u4ea4\u504f\u79fb\u91cf&#xff0c;\u7ee7\u7eed\u4e0b\u4e00\u6761<\/td>\n<\/tr>\n<tr>\n<td>ROLLBACK<\/td>\n<td>\u89c6\u4e3aSUCCESS\u5904\u7406&#xff0c;\u6253\u8b66\u544a\u65e5\u5fd7<\/td>\n<td>\u6d88\u606f\u56de\u9000\u5230\u961f\u5217&#xff0c;\u6682\u505c\u5f53\u524d\u961f\u5217<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd4\u56deSUCCESS\u65f6&#xff0c;\u4e0d\u7ba1autoCommit\u600e\u4e48\u8bbe&#xff0c;\u5faa\u73af\u90fd\u4f1a\u7ee7\u7eed\u53d6\u4e0b\u4e00\u6761\u6d88\u606f\u3002autoCommit\u53ea\u51b3\u5b9a\u504f\u79fb\u91cf\u662f\u5426\u4e0a\u62a5\u3002<\/p>\n<p>\u53e6\u5916&#xff0c;autoCommit\u4e3afalse\u52a0\u4e0a\u8fd4\u56deSUCCESS&#xff0c;\u6d88\u606f\u88ab\u6d88\u8d39\u4e86\u4f46\u504f\u79fb\u91cf\u6c38\u8fdc\u4e0d\u4f1a\u63d0\u4ea4\u7ed9Broker\u3002\u6d88\u8d39\u8005\u91cd\u542f\u540e&#xff0c;Broker\u4e0d\u77e5\u9053\u8fd9\u4e9b\u6d88\u606f\u5df2\u7ecf\u88ab\u6d88\u8d39\u8fc7&#xff0c;\u4f1a\u91cd\u65b0\u6295\u9012&#xff0c;\u5bfc\u81f4\u91cd\u590d\u6d88\u8d39\u3002\u9664\u975e\u6709\u660e\u786e\u7684\u4e8b\u52a1\u9700\u6c42&#xff08;\u6bd4\u5982\u9700\u8981\u6839\u636e\u6d88\u8d39\u7ed3\u679c\u51b3\u5b9acommit\u8fd8\u662frollback&#xff09;&#xff0c;\u4e0d\u5efa\u8bae\u5173\u95edautoCommit\u3002<\/p>\n<p>\u5982\u679c\u786e\u5b9e\u9700\u8981\u4f7f\u7528autoCommit&#061;false\u7684\u573a\u666f&#xff0c;\u6b63\u786e\u505a\u6cd5\u662f&#xff1a;\u4e1a\u52a1\u5904\u7406\u6210\u529f\u540e\u8fd4\u56deConsumeOrderlyStatus.COMMIT\u800c\u4e0d\u662fSUCCESS&#xff0c;\u8fd9\u6837\u504f\u79fb\u91cf\u624d\u4f1a\u88ab\u63d0\u4ea4\u3002<\/p>\n<h3>\u56de\u7b54\u63d0\u95ee\u8005\u7684\u95ee\u9898<\/h3>\n<p>\u63d0\u95ee\u8005\u60f3\u8981\u7684\u662f\u300c\u62ff\u51fa\u4e00\u6761\u961f\u5217\u6570\u636e&#xff0c;\u9501\u4f4f\u961f\u5217&#xff0c;\u6d88\u8d39\u5b8c\u6d88\u606f\u518d\u89e3\u9501\u300d\u7684\u6a21\u5f0f\u3002<\/p>\n<p>\u4ece\u6e90\u7801\u6765\u770b&#xff0c;RocketMQ\u7684\u539f\u751f\u5ba2\u6237\u7aef\u5df2\u7ecf\u652f\u6301\u8fd9\u4e2a\u6a21\u5f0f&#xff0c;\u53ea\u662f\u5b9e\u73b0\u65b9\u5f0f\u548c\u63d0\u95ee\u8005\u7684\u9884\u60f3\u6709\u51fa\u5165\u3002<\/p>\n<p>\u63d0\u95ee\u8005\u9884\u60f3\u7684\u662f\u6d88\u606f\u7ea7\u522b\u7684\u52a0\u9501&#xff1a;\u53d6\u4e00\u6761\u6d88\u606f&#xff0c;\u52a0\u9501&#xff0c;\u6d88\u8d39\u5b8c&#xff0c;\u89e3\u9501&#xff0c;\u518d\u53d6\u4e0b\u4e00\u6761\u3002\u6bcf\u6761\u6d88\u606f\u90fd\u7ecf\u5386\u4e00\u6b21\u52a0\u9501\u548c\u89e3\u9501\u3002<\/p>\n<p>\u5b9e\u9645\u7684\u5b9e\u73b0\u662f\u961f\u5217\u7ea7\u522b\u7684\u52a0\u9501&#xff1a;\u62ff\u5230\u961f\u5217\u9501\u4e4b\u540e&#xff0c;\u5728\u4e00\u4e2awhile\u5faa\u73af\u91cc\u8fde\u7eed\u53d6\u6d88\u606f\u6d88\u8d39&#xff0c;\u76f4\u5230\u961f\u5217\u7a7a\u4e86\u624d\u91ca\u653e\u9501\u3002\u6574\u4e2a\u8fc7\u7a0b\u4e2d\u9501\u4e00\u76f4\u6301\u6709&#xff0c;\u4e0d\u4f1a\u5728\u6d88\u606f\u4e4b\u95f4\u91ca\u653e\u3002<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827053245-6a8fcbfd989c6.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4e24\u79cd\u65b9\u5f0f\u90fd\u4fdd\u8bc1\u4e86\u6d88\u606f\u6309\u987a\u5e8f\u6d88\u8d39&#xff0c;\u533a\u522b\u53ea\u5728\u4e8e\u9501\u7684\u6301\u6709\u5468\u671f\u3002RocketMQ\u9009\u62e9\u961f\u5217\u7ea7\u522b\u7684\u9501\u662f\u51fa\u4e8e\u6027\u80fd\u8003\u8651&#xff0c;\u907f\u514d\u6bcf\u6761\u6d88\u606f\u90fd\u7ecf\u5386\u52a0\u9501\u89e3\u9501\u7684\u5f00\u9500\u3002\u5728\u6d88\u606f\u91cf\u5927\u7684\u573a\u666f\u4e0b&#xff0c;\u9891\u7e41\u52a0\u9501\u89e3\u9501\u7684\u5f00\u9500\u4e0d\u53ef\u5ffd\u7565\u3002<\/p>\n<p>\u63d0\u95ee\u8005\u4e0d\u9700\u8981\u81ea\u5df1\u5199\u4ee3\u7801\u3002\u4ed6\u770b\u5230\u7684\u65e5\u5fd7\u884c\u4e3a\u5c31\u662f\u987a\u5e8f\u6d88\u8d39\u5728\u6b63\u5e38\u5de5\u4f5c&#xff1a;\u540c\u4e00\u4e2a\u7ebf\u7a0b\u6309\u504f\u79fb\u91cf\u9012\u589e\u987a\u5e8f\u6d88\u8d39&#xff0c;\u6ca1\u6709\u5176\u4ed6\u7ebf\u7a0b\u80fd\u63d2\u961f\u3002<\/p>\n<h3>\u5c0f\u7ed3<\/h3>\n<p>\u987a\u5e8f\u6d88\u8d39\u7684\u4fdd\u8bc1\u6765\u81ea\u4e24\u5c42\u673a\u5236\u534f\u540c\u5de5\u4f5c&#xff1a;ProcessQueue\u7684consuming\u6807\u5fd7\u9632\u6b62\u91cd\u590d\u63d0\u4ea4\u6d88\u8d39\u4efb\u52a1&#xff0c;synchronized\u9501\u4fdd\u8bc1\u540c\u4e00\u961f\u5217\u540c\u4e00\u65f6\u523b\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u5728\u6d88\u8d39\u3002\u6d88\u8d39\u7ebf\u7a0b\u62ff\u5230\u9501\u540e\u8fdb\u5165while\u5faa\u73af&#xff0c;\u6309\u504f\u79fb\u91cf\u9012\u589e\u987a\u5e8f\u9010\u6761\u5904\u7406\u6d88\u606f&#xff0c;\u961f\u5217\u7a7a\u4e86\u624d\u91ca\u653e\u9501\u3002<\/p>\n<p>autoCommit\u8fd9\u4e2a\u53c2\u6570\u5bb9\u6613\u8ba9\u4eba\u4ea7\u751f\u8bef\u89e3&#xff0c;\u4ee5\u4e3a\u5b83\u80fd\u63a7\u5236\u6d88\u8d39\u662f\u5426\u7ee7\u7eed\u3002\u5b9e\u9645\u4e0a\u5b83\u53ea\u7ba1\u504f\u79fb\u91cf\u662f\u5426\u4e0a\u62a5\u7ed9Broker&#xff0c;\u548c\u6d88\u8d39\u5faa\u73af\u7684\u7ee7\u7eed\u4e0e\u5426\u6ca1\u6709\u5173\u7cfb\u3002\u5728\u9700\u8981\u7528autoCommit&#061;false\u7684\u573a\u666f\u4e0b&#xff0c;\u8981\u7528COMMIT\u800c\u4e0d\u662fSUCCESS\u6765\u89e6\u53d1\u504f\u79fb\u91cf\u63d0\u4ea4\u3002<\/p>\n<p>\u5b9e\u9645\u9879\u76ee\u4e2d&#xff0c;\u987a\u5e8f\u6d88\u8d39\u6700\u5bb9\u6613\u51fa\u95ee\u9898\u7684\u5730\u65b9\u5f80\u5f80\u4e0d\u662f\u5ba2\u6237\u7aef\u7684\u52a0\u9501\u673a\u5236&#xff0c;\u800c\u662f\u6d88\u606f\u662f\u5426\u88ab\u6b63\u786e\u8def\u7531\u5230\u4e86\u540c\u4e00\u4e2a\u961f\u5217\u3002\u5982\u679c\u4e1a\u52a1\u4e0a\u9700\u8981\u4fdd\u8bc1\u987a\u5e8f\u7684\u6d88\u606f\u5206\u6563\u5728\u4e0d\u540c\u961f\u5217&#xff0c;\u5ba2\u6237\u7aef\u518d\u600e\u4e48\u52a0\u9501\u4e5f\u65e0\u6d4e\u4e8e\u4e8b\u3002\u53d1\u9001\u7aef\u7528\u540c\u4e00\u4e2ahash key\u628a\u76f8\u5173\u6d88\u606f\u8def\u7531\u5230\u540c\u4e00\u4e2a\u961f\u5217&#xff0c;\u662f\u987a\u5e8f\u6d88\u8d39\u7684\u524d\u63d0\u6761\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u5f00\u53d1\u8005\u5728\u4f7f\u7528RocketMQ\u7684MessageListenerOrderly\u505a\u987a\u5e8f\u6d88\u8d39\u65f6&#xff0c;\u53d1\u73b0\u65e5\u5fd7\u91cc\u540c\u4e00\u4e2a\u7ebf\u7a0b\u5728\u540c\u4e00\u6beb\u79d2\u5185\u8fde\u7eed\u6253\u5370\u4e86\u591a\u6761\u6d88\u606f&#xff1a;<br \/>\n[ConsumeMessageThread_10] msg is :Hello RocketMQ 75<br \/>\n[ConsumeMessageThread_10] msg is :Hello RocketMQ 79<br \/>\n[ConsumeMessageThread_10] msg is :Hello RocketMQ 8<\/p>\n","protected":false},"author":2,"featured_media":96096,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,1187,3294,292,958],"topic":[],"class_list":["post-96098","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-java","tag-java-rocketmq","tag-rocketmq","tag-292","tag-958"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>RocketMQ\u987a\u5e8f\u6d88\u8d39\u7684\u52a0\u9501\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/96098.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RocketMQ\u987a\u5e8f\u6d88\u8d39\u7684\u52a0\u9501\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6709\u5f00\u53d1\u8005\u5728\u4f7f\u7528RocketMQ\u7684MessageListenerOrderly\u505a\u987a\u5e8f\u6d88\u8d39\u65f6&#xff0c;\u53d1\u73b0\u65e5\u5fd7\u91cc\u540c\u4e00\u4e2a\u7ebf\u7a0b\u5728\u540c\u4e00\u6beb\u79d2\u5185\u8fde\u7eed\u6253\u5370\u4e86\u591a\u6761\u6d88\u606f&#xff1a; [ConsumeMessageThread_10] msg is :Hello RocketMQ 75 [ConsumeMessageThread_10] msg is :Hello RocketMQ 79 [ConsumeMessageThread_10] msg is :Hello RocketMQ 8\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/96098.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-27T05:32:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827053244-6a8fcbfc62a4d.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/96098.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/96098.html\",\"name\":\"RocketMQ\u987a\u5e8f\u6d88\u8d39\u7684\u52a0\u9501\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-27T05:32:47+00:00\",\"dateModified\":\"2026-08-27T05:32:47+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/96098.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/96098.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/96098.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"RocketMQ\u987a\u5e8f\u6d88\u8d39\u7684\u52a0\u9501\u673a\u5236\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"RocketMQ\u987a\u5e8f\u6d88\u8d39\u7684\u52a0\u9501\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/96098.html","og_locale":"zh_CN","og_type":"article","og_title":"RocketMQ\u987a\u5e8f\u6d88\u8d39\u7684\u52a0\u9501\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6709\u5f00\u53d1\u8005\u5728\u4f7f\u7528RocketMQ\u7684MessageListenerOrderly\u505a\u987a\u5e8f\u6d88\u8d39\u65f6&#xff0c;\u53d1\u73b0\u65e5\u5fd7\u91cc\u540c\u4e00\u4e2a\u7ebf\u7a0b\u5728\u540c\u4e00\u6beb\u79d2\u5185\u8fde\u7eed\u6253\u5370\u4e86\u591a\u6761\u6d88\u606f&#xff1a; [ConsumeMessageThread_10] msg is :Hello RocketMQ 75 [ConsumeMessageThread_10] msg is :Hello RocketMQ 79 [ConsumeMessageThread_10] msg is :Hello RocketMQ 8","og_url":"https:\/\/www.wsisp.com\/helps\/96098.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-27T05:32:47+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827053244-6a8fcbfc62a4d.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/96098.html","url":"https:\/\/www.wsisp.com\/helps\/96098.html","name":"RocketMQ\u987a\u5e8f\u6d88\u8d39\u7684\u52a0\u9501\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-27T05:32:47+00:00","dateModified":"2026-08-27T05:32:47+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/96098.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/96098.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/96098.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"RocketMQ\u987a\u5e8f\u6d88\u8d39\u7684\u52a0\u9501\u673a\u5236"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/96098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=96098"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/96098\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/96096"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=96098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=96098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=96098"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=96098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}