{"id":109186,"date":"2026-09-23T14:57:07","date_gmt":"2026-09-23T06:57:07","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/109186.html"},"modified":"2026-09-23T14:57:07","modified_gmt":"2026-09-23T06:57:07","slug":"%e3%80%90%e5%9f%ba%e4%ba%8e-swoolehyperf-%e7%9a%84%e5%be%ae%e6%9c%8d%e5%8a%a1%e5%ae%9e%e6%88%98%e3%80%91%e6%b6%88%e6%81%af%e5%8f%af%e9%9d%a0%e6%80%a7%ef%bc%9a%e6%89%8b%e5%8a%a8%e7%a1%ae%e8%ae%a4","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/109186.html","title":{"rendered":"\u3010\u57fa\u4e8e Swoole+Hyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027\uff1a\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39"},"content":{"rendered":"<h3>\u3010\u57fa\u4e8e Swoole&#043;Hyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027&#xff1a;\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39<\/h3>\n<hr \/>\n<p>\u4eca\u5929\u6211\u4eec\u8fdb\u5165\u7684\u4e3b\u9898\u662f \u6d88\u606f\u53ef\u9760\u6027&#xff1a;\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39\u3002\u6628\u5929\u6211\u4eec\u5df2\u7ecf\u642d\u5efa\u4e86\u57fa\u672c\u7684 RabbitMQ \u751f\u4ea7\u8005\u548c\u6d88\u8d39\u8005&#xff0c;\u4f46\u6d88\u606f\u53ef\u80fd\u56e0\u4e3a\u6d88\u8d39\u5f02\u5e38\u800c\u4e22\u5931&#xff0c;\u6216\u8005\u56e0\u4e3a\u91cd\u590d\u6d88\u8d39\u5bfc\u81f4\u6570\u636e\u4e0d\u4e00\u81f4\u3002\u4eca\u5929\u6211\u4eec\u5c06\u4e3a\u8ba2\u5355\u6d88\u606f\u52a0\u4e0a\u53ef\u9760\u6295\u9012\u548c\u6d88\u8d39\u4fdd\u969c&#xff1a;\u901a\u8fc7\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u3001\u5e42\u7b49\u673a\u5236&#xff0c;\u786e\u4fdd\u6d88\u606f\u88ab\u6b63\u786e\u5904\u7406\u4e14\u4e0d\u4e22\u5931\u3001\u4e0d\u91cd\u590d\u3002<\/p>\n<hr \/>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260923065659-6ab3783bf381f.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>\u4eca\u65e5\u76ee\u6807<\/h4>\n<li>\u7406\u89e3\u6d88\u606f\u786e\u8ba4\u7684\u4e09\u79cd\u6a21\u5f0f&#xff08;\u81ea\u52a8ACK\u3001\u624b\u52a8ACK\u3001NACK\u91cd\u8bd5&#xff09;\u53ca\u5176\u9002\u7528\u573a\u666f\u3002<\/li>\n<li>\u914d\u7f6e RabbitMQ \u6b7b\u4fe1\u961f\u5217&#xff08;DLX&#xff09;&#xff0c;\u5c06\u65e0\u6cd5\u5904\u7406\u7684\u6d88\u606f\u8f6c\u79fb\u81f3\u6b7b\u4fe1&#xff0c;\u65b9\u4fbf\u540e\u7eed\u4eba\u5de5\u4ecb\u5165\u3002<\/li>\n<li>\u5b9e\u73b0\u5e42\u7b49\u6d88\u8d39&#xff1a;\u901a\u8fc7\u6570\u636e\u5e93\u6216 Redis \u8bb0\u5f55\u5df2\u5904\u7406\u6d88\u606f ID&#xff0c;\u9632\u6b62\u91cd\u590d\u6d88\u8d39\u5bfc\u81f4\u5e93\u5b58\u591a\u6263\u6216\u8ba2\u5355\u91cd\u590d\u3002<\/li>\n<li>\u7ed3\u5408\u6628\u5929\u8ba2\u5355\u521b\u5efa\u6848\u4f8b&#xff0c;\u6539\u9020\u6d88\u8d39\u8005\u4e3a\u53ef\u9760\u6d88\u8d39&#xff0c;\u5e76\u6a21\u62df\u5f02\u5e38\u91cd\u8bd5\u4e0e\u6b7b\u4fe1\u8f6c\u50a8\u3002<\/li>\n<li>\u6d4b\u8bd5\u6b7b\u4fe1\u961f\u5217\u7684\u5de5\u4f5c\u6d41\u7a0b&#xff0c;\u9a8c\u8bc1\u5e42\u7b49\u6027\u3002<\/li>\n<hr \/>\n<h4>\u4e00\u3001\u73af\u5883\u51c6\u5907&#xff08;\u7ea6 15 \u5206\u949f&#xff09;<\/h4>\n<p>\u7ee7\u7eed\u4f7f\u7528\u6628\u5929\u7684 RabbitMQ \u5bb9\u5668&#xff0c;\u786e\u4fdd hyperf-app \u9879\u76ee\u5df2\u5b89\u88c5 hyperf\/amqp&#xff0c;\u5e76\u4e14\u5df2\u6709 OrderCreatedProducer \u548c OrderCreatedConsumer \u57fa\u7840\u4ee3\u7801\u3002<\/p>\n<p>\u8fdb\u5165 PHP \u5bb9\u5668&#xff1a;<\/p>\n<p><span class=\"token function\">docker-compose<\/span> <span class=\"token builtin class-name\">exec<\/span> swoole <span class=\"token function\">bash<\/span><br \/>\n<span class=\"token builtin class-name\">cd<\/span> \/var\/www\/hyperf-app<\/p>\n<hr \/>\n<h4>\u4e8c\u3001\u77e5\u8bc6\u6838\u5fc3&#xff1a;\u6d88\u606f\u786e\u8ba4\u3001\u6b7b\u4fe1\u4e0e\u5e42\u7b49&#xff08;\u7ea6 1 \u5c0f\u65f6&#xff09;<\/h4>\n<h5>1. \u6d88\u606f\u786e\u8ba4&#xff08;ACK\/NACK&#xff09;<\/h5>\n<p>\u5728 RabbitMQ \u4e2d&#xff0c;\u6d88\u8d39\u8005\u5904\u7406\u6d88\u606f\u540e\u53ef\u4ee5&#xff1a;<\/p>\n<ul>\n<li>ACK&#xff1a;\u786e\u8ba4\u6d88\u606f\u5904\u7406\u6210\u529f&#xff0c;\u6d88\u606f\u4ece\u961f\u5217\u4e2d\u5220\u9664\u3002<\/li>\n<li>NACK&#xff1a;\u62d2\u7edd\u6d88\u606f&#xff0c;\u53ef\u9009\u662f\u5426\u91cd\u65b0\u5165\u961f\u3002\u5982\u679c requeue&#061;true&#xff0c;\u6d88\u606f\u4f1a\u56de\u5230\u961f\u5217\u5934\u90e8&#xff0c;\u53ef\u80fd\u88ab\u518d\u6b21\u6295\u9012&#xff08;\u53ef\u80fd\u9020\u6210\u6b7b\u5faa\u73af&#xff09;\u3002\u82e5 requeue&#061;false&#xff0c;\u6d88\u606f\u4f1a\u88ab\u4e22\u5f03\u6216\u8f6c\u5165\u6b7b\u4fe1\u961f\u5217\u3002<\/li>\n<li>\u8d85\u65f6&#xff1a;\u82e5\u6d88\u8d39\u8005\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5d29\u6e83\u6216\u8fde\u63a5\u65ad\u5f00&#xff0c;\u672a\u786e\u8ba4\u7684\u6d88\u606f\u4f1a\u81ea\u52a8\u91cd\u65b0\u5165\u961f&#xff0c;\u5b9e\u73b0\u53ef\u9760\u7684\u91cd\u65b0\u6295\u9012\u3002<\/li>\n<\/ul>\n<p>hyperf\/amqp \u9ed8\u8ba4\u8981\u6c42\u6d88\u8d39\u8005\u5fc5\u987b\u8fd4\u56de Result::ACK \u6216 Result::NACK&#xff0c;\u5426\u5219\u6d88\u606f\u4f1a\u4e00\u76f4\u6302\u8d77\u3002<\/p>\n<h5>2. \u6b7b\u4fe1\u961f\u5217&#xff08;DLX&#xff09;<\/h5>\n<p>\u6b7b\u4fe1\u961f\u5217&#xff08;Dead Letter Exchange&#xff09;\u662f RabbitMQ \u7684\u4e00\u4e2a\u7279\u6027&#xff1a;\u5f53\u6d88\u606f\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\u65f6&#xff0c;\u4f1a\u88ab\u8f6c\u53d1\u5230\u6307\u5b9a\u7684\u6b7b\u4fe1\u4ea4\u6362\u673a&#xff0c;\u7136\u540e\u8fdb\u5165\u7ed1\u5b9a\u7684\u6b7b\u4fe1\u961f\u5217&#xff1a;<\/p>\n<ul>\n<li>\u6d88\u8d39\u8005\u4e3b\u52a8\u62d2\u7edd\u4e14 requeue&#061;false\u3002<\/li>\n<li>\u6d88\u606f\u8fbe\u5230\u6700\u5927\u91cd\u8bd5\u6b21\u6570&#xff08;\u901a\u5e38\u901a\u8fc7\u6dfb\u52a0\u91cd\u8bd5\u8ba1\u6570\u5934\u5b9e\u73b0&#xff0c;\u6216\u5229\u7528\u961f\u5217\u7684 x-message-ttl \u548c x-dead-letter-exchange&#xff09;\u3002<\/li>\n<li>\u6d88\u606f\u8fc7\u671f&#xff08;TTL \u8d85\u65f6&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u6211\u4eec\u53ef\u4ee5\u5728\u521b\u5efa\u961f\u5217\u65f6\u5b9a\u4e49\u53c2\u6570 x-dead-letter-exchange \u548c x-dead-letter-routing-key&#xff0c;RabbitMQ \u5c31\u4f1a\u81ea\u52a8\u5c06\u6b7b\u4fe1\u53d1\u9001\u8fc7\u53bb\u3002<\/p>\n<h5>3. \u5e42\u7b49\u6d88\u8d39<\/h5>\n<p>\u5728\u5206\u5e03\u5f0f\u73af\u5883\u4e2d&#xff0c;\u7f51\u7edc\u6296\u52a8\u3001\u6d88\u8d39\u8005\u6545\u969c\u90fd\u53ef\u80fd\u5bfc\u81f4\u540c\u4e00\u6761\u6d88\u606f\u88ab\u6295\u9012\u591a\u6b21\u3002\u5e42\u7b49\u6d88\u8d39\u610f\u5473\u7740\u65e0\u8bba\u6d88\u8d39\u591a\u5c11\u6b21&#xff0c;\u4e1a\u52a1\u7ed3\u679c\u4e0e\u6d88\u8d39\u4e00\u6b21\u76f8\u540c\u3002\u5e38\u7528\u65b9\u6848&#xff1a;<\/p>\n<ul>\n<li>\u552f\u4e00\u7d22\u5f15&#xff1a;\u5728\u6570\u636e\u5e93\u8868\u4e2d\u4f7f\u7528 order_id \u552f\u4e00\u7ea6\u675f&#xff0c;\u91cd\u590d\u63d2\u5165\u4f1a\u5931\u8d25\u3002<\/li>\n<li>\u72b6\u6001\u68c0\u67e5&#xff1a;\u5904\u7406\u524d\u68c0\u67e5\u8ba2\u5355\u72b6\u6001&#xff0c;\u5df2\u5904\u7406\u5219\u8df3\u8fc7\u3002<\/li>\n<li>Redis SETNX&#xff1a;\u5904\u7406\u524d\u5728 Redis \u4e2d\u5c1d\u8bd5\u8bbe\u7f6e msg_id \u952e&#xff0c;\u5df2\u5b58\u5728\u5219\u8df3\u8fc7\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u4e09\u3001\u5b9e\u6218&#xff1a;\u6539\u9020\u6d88\u8d39\u8005\u4e3a\u53ef\u9760\u4e14\u5e42\u7b49&#xff08;\u7ea6 2.5 \u5c0f\u65f6&#xff09;<\/h4>\n<h5>\u6b65\u9aa4 1&#xff1a;\u8bbe\u8ba1\u6b7b\u4fe1\u961f\u5217\u7ed3\u6784<\/h5>\n<p>\u6211\u4eec\u9700\u8981\u521b\u5efa\u4ee5\u4e0b\u4ea4\u6362\u673a\u548c\u961f\u5217&#xff1a;<\/p>\n<ul>\n<li>\u6b63\u5e38\u4ea4\u6362\u673a&#xff1a;order.exchange (direct)<\/li>\n<li>\u6b63\u5e38\u961f\u5217&#xff1a;order.queue&#xff0c;\u8bbe\u7f6e\u6b7b\u4fe1\u4ea4\u6362\u673a\u4e3a order.dlx.exchange&#xff0c;\u6b7b\u4fe1\u8def\u7531\u952e\u4e3a order.dead<\/li>\n<li>\u6b7b\u4fe1\u4ea4\u6362\u673a&#xff1a;order.dlx.exchange (direct)<\/li>\n<li>\u6b7b\u4fe1\u961f\u5217&#xff1a;order.dead.queue<\/li>\n<\/ul>\n<p>hyperf\/amqp \u53ef\u4ee5\u901a\u8fc7\u6ce8\u89e3\u7684 arguments \u53c2\u6570\u5728\u58f0\u660e\u961f\u5217\u65f6\u6ce8\u5165\u6b7b\u4fe1\u8bbe\u7f6e\u3002<\/p>\n<h5>\u6b65\u9aa4 2&#xff1a;\u4fee\u6539\u6d88\u8d39\u8005\u6ce8\u89e3&#xff0c;\u589e\u52a0\u6b7b\u4fe1\u914d\u7f6e<\/h5>\n<p>\u7f16\u8f91 app\/Amqp\/Consumer\/OrderCreatedConsumer.php&#xff1a;<\/p>\n<p><span class=\"token delimiter important\">&lt;?php<\/span><br \/>\n<span class=\"token keyword\">namespace<\/span> <span class=\"token package\">App<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Consumer<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">use<\/span> <span class=\"token package\">Hyperf<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Annotation<span class=\"token punctuation\">\\\\<\/span>Consumer<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">use<\/span> <span class=\"token package\">Hyperf<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Message<span class=\"token punctuation\">\\\\<\/span>ConsumerMessage<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">use<\/span> <span class=\"token package\">Hyperf<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Result<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token attribute\"><span class=\"token delimiter punctuation\">#[<\/span><span class=\"token attribute-content\"><span class=\"token attribute-class-name class-name\">Consumer<\/span><span class=\"token punctuation\">(<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">exchange<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;order.exchange&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">routingKey<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;order.created&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">queue<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;order.queue&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">name<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;OrderCreatedConsumer&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">nums<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">deadLetterExchange<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;order.dlx.exchange&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">deadLetterRoutingKey<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;order.dead&#039;<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><\/span><span class=\"token delimiter punctuation\">]<\/span><\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name-definition class-name\">OrderCreatedConsumer<\/span> <span class=\"token keyword\">extends<\/span> <span class=\"token class-name\">ConsumerMessage<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function-definition function\">consume<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$data<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token keyword return-type\">string<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token variable\">$orderId<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token variable\">$data<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string single-quoted-string\">&#039;order_id&#039;<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">??<\/span> <span class=\"token string single-quoted-string\">&#039;unknown&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">echo<\/span> <span class=\"token string double-quoted-string\">&#034;[x] \u5904\u7406\u8ba2\u5355: <span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token variable\">$orderId<\/span><span class=\"token punctuation\">}<\/span><\/span>\\\\n&#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u6a21\u62df\u5e42\u7b49\u6027\u68c0\u67e5&#xff1a;Redis \u8bb0\u5f55\u5df2\u5904\u7406\u8ba2\u5355<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u6b64\u5904\u7528\u9759\u6001\u53d8\u91cf\u6a21\u62df&#xff0c;\u5b9e\u9645\u5e94\u4f7f\u7528 Redis SETNX<\/span><br \/>\n        <span class=\"token keyword\">static<\/span> <span class=\"token variable\">$processed<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">isset<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$processed<\/span><span class=\"token punctuation\">[<\/span><span class=\"token variable\">$orderId<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token keyword\">echo<\/span> <span class=\"token string double-quoted-string\">&#034;[x] \u8ba2\u5355 <span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token variable\">$orderId<\/span><span class=\"token punctuation\">}<\/span><\/span> \u5df2\u5904\u7406&#xff0c;\u8df3\u8fc7\\\\n&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token class-name static-context\">Result<\/span><span class=\"token operator\">::<\/span><span class=\"token constant\">ACK<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u6a21\u62df\u968f\u673a\u5931\u8d25&#xff08;50% \u51e0\u7387&#xff09;<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">rand<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token keyword\">echo<\/span> <span class=\"token string double-quoted-string\">&#034;[x] \u8ba2\u5355 <span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token variable\">$orderId<\/span><span class=\"token punctuation\">}<\/span><\/span> \u5904\u7406\u5931\u8d25&#xff0c;\u62d2\u7edd\u6d88\u606f\u4e14\u4e0d\u91cd\u8bd5\\\\n&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token comment\">\/\/ \u8fd4\u56de NACK \u4e14 requeue&#061;false&#xff0c;\u6d88\u606f\u5c06\u8fdb\u5165\u6b7b\u4fe1<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token class-name static-context\">Result<\/span><span class=\"token operator\">::<\/span><span class=\"token constant\">NACK<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u5904\u7406\u6210\u529f&#xff0c;\u6807\u8bb0\u5df2\u5904\u7406<\/span><br \/>\n        <span class=\"token variable\">$processed<\/span><span class=\"token punctuation\">[<\/span><span class=\"token variable\">$orderId<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token constant boolean\">true<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u5b9e\u9645\u4e1a\u52a1&#xff1a;\u6263\u51cf\u5e93\u5b58&#8230;<\/span><br \/>\n        <span class=\"token keyword\">echo<\/span> <span class=\"token string double-quoted-string\">&#034;[x] \u8ba2\u5355 <span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token variable\">$orderId<\/span><span class=\"token punctuation\">}<\/span><\/span> \u5904\u7406\u6210\u529f\\\\n&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token class-name static-context\">Result<\/span><span class=\"token operator\">::<\/span><span class=\"token constant\">ACK<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u89e3\u91ca&#xff1a;<\/p>\n<ul>\n<li>\u5728 #[Consumer] \u4e2d\u589e\u52a0\u4e86 deadLetterExchange \u548c deadLetterRoutingKey \u53c2\u6570&#xff0c;Hyperf \u4f1a\u5728\u58f0\u660e\u961f\u5217\u65f6\u81ea\u52a8\u8bbe\u7f6e\u6b7b\u4fe1\u89c4\u5219\u3002<\/li>\n<li>\u6a21\u62df\u968f\u673a\u5931\u8d25&#xff0c;\u5f53\u5904\u7406\u5931\u8d25\u65f6\u8fd4\u56de Result::NACK&#xff08;Hyperf \u81ea\u52a8\u8bbe\u7f6e requeue&#061;false&#xff09;&#xff0c;\u6d88\u606f\u5c06\u53d8\u4e3a\u6b7b\u4fe1\u3002<\/li>\n<li>\u5e42\u7b49\u68c0\u67e5\u4f7f\u7528\u9759\u6001\u53d8\u91cf\u6f14\u793a&#xff0c;\u5b9e\u9645\u5e94\u66ff\u6362\u4e3a\u6301\u4e45\u5316\u5b58\u50a8\u3002<\/li>\n<\/ul>\n<h5>\u6b65\u9aa4 3&#xff1a;\u521b\u5efa\u6b7b\u4fe1\u6d88\u8d39\u8005&#xff08;\u7528\u4e8e\u76d1\u63a7\u6216\u4eba\u5de5\u5904\u7406&#xff09;<\/h5>\n<p>\u65b0\u5efa app\/Amqp\/Consumer\/OrderDeadConsumer.php&#xff1a;<\/p>\n<p><span class=\"token delimiter important\">&lt;?php<\/span><br \/>\n<span class=\"token keyword\">namespace<\/span> <span class=\"token package\">App<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Consumer<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">use<\/span> <span class=\"token package\">Hyperf<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Annotation<span class=\"token punctuation\">\\\\<\/span>Consumer<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">use<\/span> <span class=\"token package\">Hyperf<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Message<span class=\"token punctuation\">\\\\<\/span>ConsumerMessage<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">use<\/span> <span class=\"token package\">Hyperf<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Result<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token attribute\"><span class=\"token delimiter punctuation\">#[<\/span><span class=\"token attribute-content\"><span class=\"token attribute-class-name class-name\">Consumer<\/span><span class=\"token punctuation\">(<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">exchange<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;order.dlx.exchange&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">routingKey<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;order.dead&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">queue<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;order.dead.queue&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">name<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;OrderDeadConsumer&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token attribute-class-name class-name\">nums<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">1<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><\/span><span class=\"token delimiter punctuation\">]<\/span><\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name-definition class-name\">OrderDeadConsumer<\/span> <span class=\"token keyword\">extends<\/span> <span class=\"token class-name\">ConsumerMessage<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function-definition function\">consume<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$data<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token keyword return-type\">string<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token variable\">$orderId<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token variable\">$data<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string single-quoted-string\">&#039;order_id&#039;<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">??<\/span> <span class=\"token string single-quoted-string\">&#039;unknown&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">echo<\/span> <span class=\"token string double-quoted-string\">&#034;[\u6b7b\u4fe1] \u6536\u5230\u5931\u8d25\u8ba2\u5355: <span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token variable\">$orderId<\/span><span class=\"token punctuation\">}<\/span><\/span>&#xff0c;\u8bb0\u5f55\u544a\u8b66\u5e76\u901a\u77e5\u8fd0\u7ef4\\\\n&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u8bb0\u5f55\u5230\u6570\u636e\u5e93\u6216\u53d1\u9001\u9489\u9489\u901a\u77e5<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token class-name static-context\">Result<\/span><span class=\"token operator\">::<\/span><span class=\"token constant\">ACK<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u6837\u4efb\u4f55\u8fdb\u5165\u6b7b\u4fe1\u7684\u8ba2\u5355\u90fd\u4f1a\u88ab\u8be5\u6d88\u8d39\u8005\u8bb0\u5f55&#xff0c;\u800c\u4e0d\u81f3\u4e8e\u9ed8\u9ed8\u4e22\u5931\u3002<\/p>\n<h5>\u6b65\u9aa4 4&#xff1a;\u914d\u7f6e\u81ea\u52a8\u521b\u5efa\u6b7b\u4fe1\u961f\u5217\u548c\u4ea4\u6362\u673a<\/h5>\n<p>\u4e3a\u4e86\u8ba9\u6d88\u8d39\u8005\u542f\u52a8\u65f6\u81ea\u52a8\u521b\u5efa\u6240\u9700\u7684\u4ea4\u6362\u673a\u548c\u961f\u5217&#xff0c;\u6211\u4eec\u9700\u8981\u5728\u6d88\u8d39\u8005\u6ce8\u89e3\u4e2d\u58f0\u660e\u8db3\u591f\u7684\u53c2\u6570\u3002Hyperf \u7684 &#064;Consumer \u6ce8\u89e3\u4f1a\u81ea\u52a8\u6839\u636e\u540d\u79f0\u521b\u5efa\u4ea4\u6362\u673a\u548c\u961f\u5217&#xff0c;\u4f46\u6b7b\u4fe1\u4ea4\u6362\u673a\u548c\u961f\u5217\u9700\u8981\u624b\u52a8\u58f0\u660e&#xff0c;\u6216\u8005\u901a\u8fc7 RabbitMQ \u7ba1\u7406\u754c\u9762\u9884\u5148\u521b\u5efa\u3002\u66f4\u4f18\u96c5\u7684\u65b9\u5f0f\u662f\u7f16\u5199\u4e00\u4e2a BootApplication \u76d1\u542c\u5668&#xff0c;\u5728\u5e94\u7528\u542f\u52a8\u65f6\u901a\u8fc7 AMQP \u7ba1\u7406\u63a5\u53e3\u521b\u5efa\u62d3\u6251\u3002<\/p>\n<p>\u4f46\u4e3a\u4e86\u7b80\u5316&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5728\u6d88\u8d39\u8005\u6ce8\u89e3\u4e2d\u4f7f\u7528 arguments \u76f4\u63a5\u4f20\u9012\u6b7b\u4fe1\u914d\u7f6e&#xff0c;\u5e76\u4e14\u624b\u52a8\u521b\u5efa\u6b7b\u4fe1\u961f\u5217\u3002\u7136\u800c Hyperf \u7684\u6d88\u8d39\u8005\u82e5\u6ca1\u6709\u5bf9\u5e94\u7684\u751f\u4ea7\u8005\u548c\u58f0\u660e&#xff0c;\u4e0d\u4f1a\u4e3b\u52a8\u521b\u5efa\u6b7b\u4fe1\u4ea4\u6362\u673a\u548c\u961f\u5217\u3002\u6211\u4eec\u53ef\u4ee5\u7528 RabbitMQ \u7ba1\u7406\u754c\u9762\u624b\u52a8\u521b\u5efa&#xff0c;\u6216\u8005\u4f9d\u8d56\u6d88\u8d39\u8005\u9996\u6b21\u8fd0\u884c\u65f6\u7684\u58f0\u660e\u3002<\/p>\n<p>\u5176\u5b9e&#xff0c;\u5f53\u6d88\u8d39\u8005\u5e26\u6709 deadLetterExchange \u53c2\u6570\u65f6&#xff0c;Hyperf \u4f1a\u5728\u58f0\u660e order.queue \u65f6\u8bbe\u7f6e x-dead-letter-exchange&#xff0c;\u4f46\u6b7b\u4fe1\u4ea4\u6362\u673a\u672c\u8eab\u9700\u8981\u88ab\u521b\u5efa\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 #[Producer] \u6ce8\u89e3\u5b9a\u4e49\u4e00\u4e2a\u6b7b\u4fe1\u751f\u4ea7\u8005&#xff08;\u5373\u4f7f\u4e0d\u7528\u5b83\u53d1\u9001\u6d88\u606f&#xff09;&#xff0c;\u5b83\u4f1a\u5728\u542f\u52a8\u65f6\u521b\u5efa\u4ea4\u6362\u673a\u548c\u961f\u5217\u3002<\/p>\n<p>\u65b0\u5efa app\/Amqp\/Producer\/OrderDeadProducer.php&#xff08;\u4ec5\u7528\u4e8e\u58f0\u660e\u62d3\u6251&#xff09;&#xff1a;<\/p>\n<p><span class=\"token delimiter important\">&lt;?php<\/span><br \/>\n<span class=\"token keyword\">namespace<\/span> <span class=\"token package\">App<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Producer<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">use<\/span> <span class=\"token package\">Hyperf<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Annotation<span class=\"token punctuation\">\\\\<\/span>Producer<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">use<\/span> <span class=\"token package\">Hyperf<span class=\"token punctuation\">\\\\<\/span>Amqp<span class=\"token punctuation\">\\\\<\/span>Message<span class=\"token punctuation\">\\\\<\/span>ProducerMessage<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token attribute\"><span class=\"token delimiter punctuation\">#[<\/span><span class=\"token attribute-content\"><span class=\"token attribute-class-name class-name\">Producer<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attribute-class-name class-name\">exchange<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;order.dlx.exchange&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token attribute-class-name class-name\">routingKey<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string single-quoted-string\">&#039;order.dead&#039;<\/span><span class=\"token punctuation\">)<\/span><\/span><span class=\"token delimiter punctuation\">]<\/span><\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name-definition class-name\">OrderDeadProducer<\/span> <span class=\"token keyword\">extends<\/span> <span class=\"token class-name\">ProducerMessage<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function-definition function\">__construct<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword type-hint\">array<\/span> <span class=\"token variable\">$data<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token variable\">$this<\/span><span class=\"token operator\">-&gt;<\/span><span class=\"token property\">payload<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token variable\">$data<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u540c\u65f6&#xff0c;\u4e3a\u4e86\u8ba9\u961f\u5217 order.dead.queue \u88ab\u521b\u5efa&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5728\u6b7b\u4fe1\u6d88\u8d39\u8005\u4e2d\u786e\u4fdd\u961f\u5217\u58f0\u660e\u5b58\u5728&#xff08;\u901a\u8fc7\u6d88\u8d39\u6ce8\u89e3\u7684 queue \u53c2\u6570&#xff0c;\u5df2\u5305\u542b&#xff09;\u3002\u542f\u52a8\u6d88\u8d39\u8005\u8fdb\u7a0b\u65f6&#xff0c;\u8fd9\u4e9b\u4ea4\u6362\u673a\u548c\u961f\u5217\u4f1a\u88ab\u81ea\u52a8\u521b\u5efa&#xff08;\u5982\u679c RabbitMQ \u6709\u521b\u5efa\u6743\u9650&#xff09;\u3002\u91cd\u542f\u670d\u52a1\u540e\u68c0\u67e5\u7ba1\u7406\u754c\u9762\u3002<\/p>\n<h5>\u6b65\u9aa4 5&#xff1a;\u589e\u5f3a\u5e42\u7b49\u6027\u5b9e\u73b0&#xff08;\u4f7f\u7528 Redis&#xff09;<\/h5>\n<p>\u5728 OrderCreatedConsumer \u4e2d\u6ce8\u5165 Redis&#xff0c;\u4f7f\u7528 SETNX \u4fdd\u8bc1\u552f\u4e00\u6027\u3002<\/p>\n<p><span class=\"token keyword\">use<\/span> <span class=\"token package\">Hyperf<span class=\"token punctuation\">\\\\<\/span>Redis<span class=\"token punctuation\">\\\\<\/span>Redis<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token attribute\"><span class=\"token delimiter punctuation\">#[<\/span><span class=\"token attribute-content\"><span class=\"token attribute-class-name class-name\">Inject<\/span><\/span><span class=\"token delimiter punctuation\">]<\/span><\/span><br \/>\n<span class=\"token keyword\">private<\/span> <span class=\"token class-name type-declaration\">Redis<\/span> <span class=\"token variable\">$redis<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">public<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function-definition function\">consume<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$data<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token keyword return-type\">string<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token variable\">$orderId<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token variable\">$data<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string single-quoted-string\">&#039;order_id&#039;<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">??<\/span> <span class=\"token string single-quoted-string\">&#039;unknown&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token variable\">$idempotentKey<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token string single-quoted-string\">&#039;order:processed:&#039;<\/span> <span class=\"token operator\">.<\/span> <span class=\"token variable\">$orderId<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u5c1d\u8bd5\u8bbe\u7f6e\u5e42\u7b49\u952e&#xff0c;\u4ec5\u5f53\u4e0d\u5b58\u5728\u65f6\u8bbe\u7f6e\u6210\u529f<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span><span class=\"token variable\">$this<\/span><span class=\"token operator\">-&gt;<\/span><span class=\"token property\">redis<\/span><span class=\"token operator\">-&gt;<\/span><span class=\"token function\">set<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$idempotentKey<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string single-quoted-string\">&#039;NX&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string single-quoted-string\">&#039;EX&#039;<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token number\">3600<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">echo<\/span> <span class=\"token string double-quoted-string\">&#034;[x] \u8ba2\u5355 <span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token variable\">$orderId<\/span><span class=\"token punctuation\">}<\/span><\/span> \u5df2\u5904\u7406&#xff0c;\u5e42\u7b49\u8df3\u8fc7\\\\n&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token class-name static-context\">Result<\/span><span class=\"token operator\">::<\/span><span class=\"token constant\">ACK<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ &#8230; \u4e1a\u52a1\u5904\u7406<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token class-name static-context\">Result<\/span><span class=\"token operator\">::<\/span><span class=\"token constant\">ACK<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u6837\u5c31\u5b9e\u73b0\u4e86\u57fa\u4e8e Redis \u7684\u5e42\u7b49\u6d88\u8d39&#xff0c;\u5373\u4f7f\u6d88\u606f\u91cd\u590d\u6295\u9012&#xff0c;\u4e5f\u53ea\u6709\u7b2c\u4e00\u6b21\u4f1a\u88ab\u5904\u7406\u3002<\/p>\n<h5>\u6b65\u9aa4 6&#xff1a;\u6a21\u62df\u5f02\u5e38\u548c\u91cd\u8bd5&#xff0c;\u9a8c\u8bc1\u6b7b\u4fe1<\/h5>\n<p>\u91cd\u542f hyperf-app \u4f7f\u914d\u7f6e\u751f\u6548\u3002<\/p>\n<p>\u4f7f\u7528 curl \u521b\u5efa\u591a\u4e2a\u8ba2\u5355&#xff1a;<\/p>\n<p><span class=\"token keyword\">for<\/span> <span class=\"token for-or-select variable\">i<\/span> <span class=\"token keyword\">in<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">..<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">do<\/span><br \/>\n  <span class=\"token function\">curl<\/span> <span class=\"token parameter variable\">-X<\/span> POST http:\/\/localhost:9501\/orders\/create <span class=\"token parameter variable\">-d<\/span> <span class=\"token string\">&#034;user_id&#061;1&amp;product_id&#061;1&amp;amount&#061;99&#034;<\/span><br \/>\n  <span class=\"token builtin class-name\">echo<\/span><br \/>\n<span class=\"token keyword\">done<\/span><\/p>\n<p>\u89c2\u5bdf\u63a7\u5236\u53f0\u8f93\u51fa&#xff1a;<\/p>\n<ul>\n<li>\u90e8\u5206\u8ba2\u5355\u5904\u7406\u6210\u529f\u3002<\/li>\n<li>\u7ea6 50% \u7684\u8ba2\u5355\u56e0\u968f\u673a\u5931\u8d25\u8fd4\u56de NACK&#xff0c;\u8fd9\u4e9b\u6d88\u606f\u4f1a\u8fdb\u5165\u6b7b\u4fe1\u961f\u5217\u3002<\/li>\n<li>\u6b7b\u4fe1\u6d88\u8d39\u8005\u4f1a\u6253\u5370 [\u6b7b\u4fe1] \u6536\u5230\u5931\u8d25\u8ba2\u5355: &#8230;\u3002<\/li>\n<\/ul>\n<p>\u767b\u5f55 RabbitMQ \u7ba1\u7406\u754c\u9762&#xff1a;<\/p>\n<ul>\n<li>\u67e5\u770b order.queue&#xff0c;\u6d88\u606f\u4f1a\u88ab\u6d88\u8d39\u6216\u8fdb\u5165\u6b7b\u4fe1\u3002<\/li>\n<li>order.dead.queue \u4e2d\u4f1a\u6709\u6b7b\u4fe1\u6d88\u606f\u3002<\/li>\n<li>\u6b7b\u4fe1\u6d88\u606f\u88ab OrderDeadConsumer \u6d88\u8d39\u540e\u6d88\u5931\u3002<\/li>\n<\/ul>\n<h5>\u6b65\u9aa4 7&#xff1a;\u5b9e\u73b0\u5ef6\u8fdf\u6d88\u606f&#xff08;\u8ba2\u5355\u8d85\u65f6\u53d6\u6d88&#xff09;\u601d\u8def<\/h5>\n<p>RabbitMQ \u6ca1\u6709\u5185\u7f6e\u5ef6\u8fdf\u961f\u5217&#xff0c;\u4f46\u53ef\u4ee5\u901a\u8fc7 TTL &#043; \u6b7b\u4fe1\u7ec4\u5408\u5b9e\u73b0&#xff1a;<\/p>\n<ul>\n<li>\u5b9a\u4e49\u4e00\u4e2a order.delay.queue&#xff0c;\u8bbe\u7f6e x-message-ttl: 30000&#xff08;30\u79d2&#xff09;\u548c x-dead-letter-exchange: order.exchange\u3001x-dead-letter-routing-key: order.cancel\u3002<\/li>\n<li>\u5f53\u9700\u8981\u5ef6\u8fdf\u65f6&#xff0c;\u53d1\u9001\u6d88\u606f\u5230\u8be5\u961f\u5217&#xff08;\u800c\u4e0d\u662f\u76f4\u63a5\u5230 order.created&#xff09;\u3002\u6d88\u606f\u5728\u961f\u5217\u4e2d\u5b58\u6d3b 30 \u79d2\u540e\u8fc7\u671f&#xff0c;\u6210\u4e3a\u6b7b\u4fe1&#xff0c;\u91cd\u65b0\u88ab\u6295\u9012\u5230 order.exchange \u5e76\u8def\u7531\u5230 order.cancel&#xff0c;\u7531\u53d6\u6d88\u6d88\u8d39\u8005\u5904\u7406\u3002<\/li>\n<\/ul>\n<p>\u4eca\u5929\u53ef\u4ee5\u5148\u521b\u5efa\u8fd9\u6837\u7684\u62d3\u6251\u7ed3\u6784&#xff0c;\u5e76\u5728\u8ba2\u5355\u521b\u5efa\u65f6\u540c\u65f6\u53d1\u9001\u4e00\u4e2a\u5ef6\u8fdf\u6d88\u606f\u5230 order.delay.queue&#xff0c;\u5b9e\u73b0 30 \u79d2\u540e\u68c0\u67e5\u8ba2\u5355\u72b6\u6001\u5e76\u81ea\u52a8\u53d6\u6d88\u3002\u8fd9\u4e00\u90e8\u5206\u53ef\u4ee5\u4f5c\u4e3a\u6311\u6218\u4efb\u52a1\u3002<\/p>\n<hr \/>\n<h4>\u56db\u3001\u6210\u679c\u6d4b\u8bd5\u4e0e\u9a8c\u8bc1&#xff08;\u7ea6 1 \u5c0f\u65f6&#xff09;<\/h4>\n<h5>\u6d4b\u8bd5\u6e05\u5355<\/h5>\n<table>\n<tr>\u68c0\u9a8c\u9879\u65b9\u6cd5\u901a\u8fc7\u6807\u51c6<\/tr>\n<tbody>\n<tr>\n<td>\u624b\u52a8\u786e\u8ba4 ACK<\/td>\n<td>\u6d88\u8d39\u8005\u6210\u529f\u5904\u7406\u540e\u8fd4\u56de Result::ACK&#xff0c;\u961f\u5217\u6d88\u606f\u79fb\u9664<\/td>\n<td>\u63a7\u5236\u53f0\u6253\u5370\u6210\u529f&#xff0c;\u7ba1\u7406\u754c\u9762\u961f\u5217\u6d88\u606f\u6570\u51cf\u5c11<\/td>\n<\/tr>\n<tr>\n<td>\u624b\u52a8\u62d2\u7edd NACK<\/td>\n<td>\u6d88\u8d39\u8005\u5904\u7406\u5931\u8d25\u8fd4\u56de Result::NACK&#xff08;requeue&#061;false&#xff09;<\/td>\n<td>\u6d88\u606f\u8fdb\u5165\u6b7b\u4fe1\u961f\u5217&#xff0c;\u4e0d\u5728\u539f\u961f\u5217<\/td>\n<\/tr>\n<tr>\n<td>\u6b7b\u4fe1\u961f\u5217<\/td>\n<td>\u67e5\u770b RabbitMQ \u7ba1\u7406\u754c\u9762 order.dead.queue<\/td>\n<td>\u5b58\u5728\u6b7b\u4fe1\u6d88\u606f&#xff0c;\u4e14\u88ab\u6b7b\u4fe1\u6d88\u8d39\u8005\u5904\u7406<\/td>\n<\/tr>\n<tr>\n<td>\u5e42\u7b49\u6027 (Redis)<\/td>\n<td>\u53d1\u9001\u76f8\u540c order_id \u7684\u6d88\u606f\u4e24\u6b21&#xff0c;\u89c2\u5bdf\u65e5\u5fd7<\/td>\n<td>\u7b2c\u4e8c\u6b21\u663e\u793a\u201c\u5df2\u5904\u7406&#xff0c;\u8df3\u8fc7\u201d<\/td>\n<\/tr>\n<tr>\n<td>\u6d88\u8d39\u8005\u5d29\u6e83\u6d88\u606f\u4e0d\u4e22<\/td>\n<td>\u5904\u7406\u8fc7\u7a0b\u4e2d\u6740\u6389\u6d88\u8d39\u8005\u8fdb\u7a0b&#xff08;Ctrl&#043;C&#xff09;&#xff0c;\u6d88\u606f\u91cd\u65b0\u5165\u961f<\/td>\n<td>\u6d88\u606f\u4e0d\u4f1a\u88ab\u786e\u8ba4&#xff0c;\u91cd\u65b0\u6295\u9012<\/td>\n<\/tr>\n<tr>\n<td>\u6b7b\u4fe1\u6d88\u8d39\u8005\u901a\u77e5<\/td>\n<td>\u6b7b\u4fe1\u6d88\u8d39\u8005\u53ef\u5199\u5165\u65e5\u5fd7\u6216\u53d1\u9001\u544a\u8b66<\/td>\n<td>\u6b7b\u4fe1\u88ab\u8bb0\u5f55&#xff0c;\u4e0d\u518d\u4e22\u5931<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>\u5e38\u89c1\u95ee\u9898<\/h5>\n<ul>\n<li>\u6b7b\u4fe1\u961f\u5217\u672a\u521b\u5efa&#xff1a;\u68c0\u67e5\u6d88\u8d39\u8005\u6ce8\u89e3\u4e2d\u7684 deadLetterExchange \u548c deadLetterRoutingKey \u662f\u5426\u62fc\u5199\u6b63\u786e&#xff1b;\u786e\u8ba4 RabbitMQ \u4e2d\u6709\u5bf9\u5e94\u6b7b\u4fe1\u4ea4\u6362\u673a&#xff08;\u53ef\u901a\u8fc7\u7ba1\u7406\u754c\u9762\u6216\u751f\u4ea7\u8005\u6ce8\u89e3\u521b\u5efa&#xff09;\u3002<\/li>\n<li>NACK \u540e\u6d88\u606f\u76f4\u63a5\u6d88\u5931&#xff1a;\u5982\u679c\u6ca1\u6709\u914d\u7f6e\u6b7b\u4fe1&#xff0c;\u4e14 requeue&#061;false&#xff0c;\u6d88\u606f\u4f1a\u88ab\u4e22\u5f03\u3002\u52a1\u5fc5\u914d\u7f6e\u6b7b\u4fe1\u3002<\/li>\n<li>\u5e42\u7b49\u952e\u672a\u751f\u6548&#xff1a;\u786e\u8ba4 Redis \u8fde\u63a5\u6b63\u5e38&#xff0c;\u952e\u7684\u8fc7\u671f\u65f6\u95f4\u5408\u7406\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u4e94\u3001\u4eca\u65e5\u4f5c\u4e1a\u4e0e\u5b66\u4e60\u4ea7\u51fa<\/h4>\n<li>\u63d0\u4ea4\u4ee3\u7801&#xff1a;\u5c06\u6539\u9020\u540e\u7684\u6d88\u8d39\u8005\u3001\u6b7b\u4fe1\u751f\u4ea7\u8005\u3001\u6b7b\u4fe1\u6d88\u8d39\u8005\u3001\u5e42\u7b49\u903b\u8f91\u7b49\u63d0\u4ea4\u5230 Git\u3002<\/li>\n<li>\u5b8c\u5584\u5ef6\u8fdf\u961f\u5217&#xff1a;\n<ul>\n<li>\u521b\u5efa order.delay.queue \u548c\u76f8\u5173\u4ea4\u6362\u7ed1\u5b9a&#xff0c;\u5b9e\u73b0\u8ba2\u5355\u521b\u5efa 30 \u79d2\u540e\u81ea\u52a8\u68c0\u67e5\u652f\u4ed8\u72b6\u6001&#xff0c;\u672a\u652f\u4ed8\u5219\u53d6\u6d88\u3002<\/li>\n<li>\u5728\u6d88\u8d39\u8005\u4e2d\u5b9e\u73b0\u53d6\u6d88\u903b\u8f91&#xff08;\u66f4\u65b0\u8ba2\u5355\u72b6\u6001\u4e3a\u201c\u5df2\u53d6\u6d88\u201d&#xff0c;\u6062\u590d\u5e93\u5b58&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5b66\u4e60\u7b14\u8bb0&#xff1a;\n<ul>\n<li>\u753b\u51fa\u6d88\u606f\u7684\u751f\u547d\u5468\u671f\u6d41\u7a0b\u56fe&#xff1a;\u53d1\u5e03 \u2192 \u6b63\u5e38\u6d88\u8d39 \u2192 \u91cd\u8bd5 \u2192 \u6b7b\u4fe1 \u2192 \u544a\u8b66\u3002<\/li>\n<li>\u89e3\u91ca\u4e3a\u4ec0\u4e48\u5e42\u7b49\u6027\u662f\u5f02\u6b65\u6d88\u606f\u7cfb\u7edf\u7684\u201c\u5fc5\u5907\u201d\u7279\u6027&#xff0c;\u5e76\u5217\u51fa\u4e09\u79cd\u5b9e\u73b0\u65b9\u5f0f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u6311\u6218\u4efb\u52a1&#xff1a;\n<ul>\n<li>\u5b9e\u73b0\u6d88\u606f\u91cd\u8bd5&#xff1a;\u6d88\u8d39\u8005\u4e0d\u76f4\u63a5 NACK&#xff0c;\u800c\u662f\u6355\u83b7\u5f02\u5e38\u540e\u5c06\u6d88\u606f\u91cd\u65b0\u53d1\u5e03\u5230\u5e26 TTL \u7684\u91cd\u8bd5\u961f\u5217&#xff0c;\u8fbe\u5230\u91cd\u8bd5\u6b21\u6570\u4e0a\u9650\u540e\u518d\u8fdb\u5165\u6b7b\u4fe1\u3002\u8fd9\u79cd\u65b9\u5f0f\u66f4\u7075\u6d3b\u3002<\/li>\n<li>\u7f16\u5199\u4e00\u4e2a\u6d88\u606f\u8865\u507f\u63a7\u5236\u5668&#xff0c;\u901a\u8fc7\u7ba1\u7406\u63a5\u53e3\u624b\u52a8\u91cd\u65b0\u6295\u9012\u6b7b\u4fe1\u961f\u5217\u4e2d\u7684\u6d88\u606f&#xff0c;\u5b9e\u73b0\u4eba\u5de5\u4fee\u590d\u3002<\/li>\n<\/ul>\n<\/li>\n<p>\u901a\u8fc7\u4eca\u5929\u7684\u5b66\u4e60&#xff0c;\u4f60\u7684\u6d88\u606f\u7cfb\u7edf\u5177\u5907\u4e86\u4f01\u4e1a\u7ea7\u7684\u53ef\u9760\u6027&#xff1a;\u6d88\u606f\u4e0d\u4e22\u5931\u3001\u4e0d\u91cd\u590d\u3001\u5f02\u5e38\u53ef\u8ffd\u6eaf\u3002\u660e\u5929\u6211\u4eec\u5c06\u5f15\u5165 Kafka&#xff0c;\u4f53\u9a8c\u9ad8\u541e\u5410\u573a\u666f\u4e0b\u7684\u53e6\u4e00\u79cd\u6d88\u606f\u5f15\u64ce&#xff0c;\u5e76\u4e0e\u73b0\u6709 RabbitMQ \u4f53\u7cfb\u5f62\u6210\u4e92\u8865\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3010\u57fa\u4e8e SwooleHyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027&#xff1a;\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39\u4eca\u5929\u6211\u4eec\u8fdb\u5165\u7684\u4e3b\u9898\u662f \u6d88\u606f\u53ef\u9760\u6027&#xff1a;\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39\u3002\u6628\u5929\u6211\u4eec\u5df2\u7ecf\u642d\u5efa\u4e86\u57fa\u672c\u7684 RabbitMQ \u751f\u4ea7\u8005\u548c\u6d88\u8d39\u8005&#xff0c;\u4f46\u6d88\u606f\u53ef\u80fd\u56e0\u4e3a\u6d88\u8d39\u5f02\u5e38\u800c\u4e22\u5931&#xff0c;\u6216\u8005\u56e0\u4e3a\u91cd\u590d\u6d88\u8d39\u5bfc\u81f4\u6570\u636e\u4e0d\u4e00\u81f4\u3002\u4eca\u5929\u6211\u4eec\u5c06\u4e3a\u8ba2\u5355\u6d88\u606f\u52a0\u4e0a\u53ef\u9760\u6295\u9012\u548c\u6d88\u8d39\u4fdd\u969c&#xff1a;\u901a\u8fc7\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u3001\u5e42\u7b49\u673a\u5236&#xff0c;\u786e\u4fdd\u6d88\u606f\u88ab\u6b63\u786e\u5904\u7406\u4e14\u4e0d\u4e22\u5931\u3001\u4e0d\u91cd\u590d\u3002\u4eca\u65e5\u76ee\u6807<\/p>\n","protected":false},"author":2,"featured_media":109185,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12454,230,2140,292,1348],"topic":[],"class_list":["post-109186","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-hyperf","tag-php","tag-swoole","tag-292","tag-1348"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u57fa\u4e8e Swoole+Hyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027\uff1a\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39 - \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\/109186.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u57fa\u4e8e Swoole+Hyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027\uff1a\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u3010\u57fa\u4e8e SwooleHyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027&#xff1a;\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39\u4eca\u5929\u6211\u4eec\u8fdb\u5165\u7684\u4e3b\u9898\u662f \u6d88\u606f\u53ef\u9760\u6027&#xff1a;\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39\u3002\u6628\u5929\u6211\u4eec\u5df2\u7ecf\u642d\u5efa\u4e86\u57fa\u672c\u7684 RabbitMQ \u751f\u4ea7\u8005\u548c\u6d88\u8d39\u8005&#xff0c;\u4f46\u6d88\u606f\u53ef\u80fd\u56e0\u4e3a\u6d88\u8d39\u5f02\u5e38\u800c\u4e22\u5931&#xff0c;\u6216\u8005\u56e0\u4e3a\u91cd\u590d\u6d88\u8d39\u5bfc\u81f4\u6570\u636e\u4e0d\u4e00\u81f4\u3002\u4eca\u5929\u6211\u4eec\u5c06\u4e3a\u8ba2\u5355\u6d88\u606f\u52a0\u4e0a\u53ef\u9760\u6295\u9012\u548c\u6d88\u8d39\u4fdd\u969c&#xff1a;\u901a\u8fc7\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u3001\u5e42\u7b49\u673a\u5236&#xff0c;\u786e\u4fdd\u6d88\u606f\u88ab\u6b63\u786e\u5904\u7406\u4e14\u4e0d\u4e22\u5931\u3001\u4e0d\u91cd\u590d\u3002\u4eca\u65e5\u76ee\u6807\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/109186.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-23T06:57:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260923065659-6ab3783bf381f.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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/109186.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/109186.html\",\"name\":\"\u3010\u57fa\u4e8e Swoole+Hyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027\uff1a\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-23T06:57:07+00:00\",\"dateModified\":\"2026-09-23T06:57:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/109186.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/109186.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/109186.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u57fa\u4e8e Swoole+Hyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027\uff1a\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39\"}]},{\"@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":"\u3010\u57fa\u4e8e Swoole+Hyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027\uff1a\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39 - \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\/109186.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u57fa\u4e8e Swoole+Hyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027\uff1a\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u3010\u57fa\u4e8e SwooleHyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027&#xff1a;\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39\u4eca\u5929\u6211\u4eec\u8fdb\u5165\u7684\u4e3b\u9898\u662f \u6d88\u606f\u53ef\u9760\u6027&#xff1a;\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39\u3002\u6628\u5929\u6211\u4eec\u5df2\u7ecf\u642d\u5efa\u4e86\u57fa\u672c\u7684 RabbitMQ \u751f\u4ea7\u8005\u548c\u6d88\u8d39\u8005&#xff0c;\u4f46\u6d88\u606f\u53ef\u80fd\u56e0\u4e3a\u6d88\u8d39\u5f02\u5e38\u800c\u4e22\u5931&#xff0c;\u6216\u8005\u56e0\u4e3a\u91cd\u590d\u6d88\u8d39\u5bfc\u81f4\u6570\u636e\u4e0d\u4e00\u81f4\u3002\u4eca\u5929\u6211\u4eec\u5c06\u4e3a\u8ba2\u5355\u6d88\u606f\u52a0\u4e0a\u53ef\u9760\u6295\u9012\u548c\u6d88\u8d39\u4fdd\u969c&#xff1a;\u901a\u8fc7\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u3001\u5e42\u7b49\u673a\u5236&#xff0c;\u786e\u4fdd\u6d88\u606f\u88ab\u6b63\u786e\u5904\u7406\u4e14\u4e0d\u4e22\u5931\u3001\u4e0d\u91cd\u590d\u3002\u4eca\u65e5\u76ee\u6807","og_url":"https:\/\/www.wsisp.com\/helps\/109186.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-23T06:57:07+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260923065659-6ab3783bf381f.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/109186.html","url":"https:\/\/www.wsisp.com\/helps\/109186.html","name":"\u3010\u57fa\u4e8e Swoole+Hyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027\uff1a\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-23T06:57:07+00:00","dateModified":"2026-09-23T06:57:07+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/109186.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/109186.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/109186.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u57fa\u4e8e Swoole+Hyperf \u7684\u5fae\u670d\u52a1\u5b9e\u6218\u3011\u6d88\u606f\u53ef\u9760\u6027\uff1a\u624b\u52a8\u786e\u8ba4\u3001\u6b7b\u4fe1\u961f\u5217\u4e0e\u5e42\u7b49\u6d88\u8d39"}]},{"@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\/109186","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=109186"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/109186\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/109185"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=109186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=109186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=109186"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=109186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}