{"id":16592,"date":"2025-04-18T23:02:28","date_gmt":"2025-04-18T15:02:28","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/16592.html"},"modified":"2025-04-18T23:02:28","modified_gmt":"2025-04-18T15:02:28","slug":"%e7%ac%ac%e5%8d%81%e7%ab%a0%ef%bc%9a%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%b6%88%e8%b4%b9%e8%80%85%e7%ae%a1%e7%90%86%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/16592.html","title":{"rendered":"\u7b2c\u5341\u7ae0\uff1a\u670d\u52a1\u5668\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E7%AC%AC%E4%B8%80%E8%8A%82%EF%BC%9A%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:0px\">\u7b2c\u4e00\u8282&#xff1a;\u4ee3\u7801\u5b9e\u73b0<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%201-1.Consumer%E7%B1%BB-toc\" style=\"margin-left:40px\">\u00a0 \u00a0 \u00a0 \u00a0 1-1.Consumer\u7c7b<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%201-2.QueueConsumer%E7%B1%BB-toc\" style=\"margin-left:40px\">\u00a0 \u00a0 \u00a0 \u00a0 1-2.QueueConsumer\u7c7b<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%20%C2%A01-3.QueueConsumerManger%E7%B1%BB-toc\" style=\"margin-left:40px\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a01-3.QueueConsumerManger\u7c7b<\/p>\n<p id=\"%E7%AC%AC%E4%BA%8C%E8%8A%82%EF%BC%9A%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95-toc\" style=\"margin-left:0px\">\u7b2c\u4e8c\u8282&#xff1a;\u5355\u5143\u6d4b\u8bd5<\/p>\n<p id=\"%E4%B8%8B%E6%9C%9F%E9%A2%84%E5%91%8A%EF%BC%9A-toc\" style=\"margin-left:0px\">\u4e0b\u671f\u9884\u544a&#xff1a;<\/p>\n<hr id=\"hr-toc\" \/>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u670d\u52a1\u5668\u7684\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757\u5728mqserver\u76ee\u5f55\u4e0b\u5b9e\u73b0\u3002<\/p>\n<h2 id=\"%E7%AC%AC%E4%B8%80%E8%8A%82%EF%BC%9A%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0\" style=\"background-color:transparent\">\u7b2c\u4e00\u8282&#xff1a;\u4ee3\u7801\u5b9e\u73b0<\/h2>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u521b\u5efa\u4e00\u4e2a\u540d\u4e3amq_consumer.hpp\u7684\u6587\u4ef6&#xff0c;\u6253\u5f00\u5e76\u505a\u597d\u524d\u7f6e\u5de5\u4f5c&#xff1a;<\/p>\n<p>#ifndef __M_CONSUMER_H__<br \/>\n#define __M_CONSUMER_H__<br \/>\n#include &#034;..\/mqcommon\/mq_logger.hpp&#034;<br \/>\n#include &#034;..\/mqcommon\/mq_helper.hpp&#034;<br \/>\n#include &#034;..\/mqcommon\/mq_msg.pb.h&#034;<br \/>\n\/\/ \u4ee5\u6d88\u606f\u961f\u5217\u4e3a\u5355\u5143\u7ba1\u7406\u6d88\u8d39\u8005<br \/>\n#include &lt;iostream&gt;<br \/>\n#include &lt;vector&gt;<br \/>\n#include &lt;unordered_map&gt;<br \/>\n#include &lt;mutex&gt;<br \/>\n#include &lt;functional&gt; <\/p>\n<p>namespace zd<br \/>\n{};<\/p>\n<p>#endif <\/p>\n<h3 id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%201-1.Consumer%E7%B1%BB\">\u00a0 \u00a0 \u00a0 \u00a0 1-1.Consumer\u7c7b<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8981\u7ba1\u7406\u6d88\u8d39\u8005&#xff0c;\u9996\u5148\u8981\u6709\u6d88\u8d39\u8005&#xff0c;\u5b9a\u4e49class Consumer\u7c7b&#xff0c;\u5b83\u7684\u5b9e\u73b0\u5982\u4e0b&#xff1a;<\/p>\n<p>     \/\/ \u6d88\u8d39\u8005\u7684\u56de\u8c03\u51fd\u6570\u7c7b\u578b<br \/>\n    using ConsumerCallback &#061; std::function&lt;void(const std::string,const BasicProperties*,const std::string)&gt;;<\/p>\n<p>    class Consumer<br \/>\n    {<br \/>\n        public:<br \/>\n            using ptr &#061; std::shared_ptr&lt;Consumer&gt;;<\/p>\n<p>            std::string tag;            \/\/ \u6d88\u8d39\u8005\u552f\u4e00\u6807\u8bc6<br \/>\n            std::string qname;          \/\/ \u6d88\u8d39\u8005\u8ba2\u9605\u7684\u961f\u5217\u540d\u79f0<br \/>\n            bool auto_ack;              \/\/ \u81ea\u52a8\u786e\u8ba4\u6807\u5fd7<br \/>\n            ConsumerCallback callback;  \/\/ \u8ba2\u9605\u961f\u5217\u6536\u5230\u6d88\u606f\u540e\u8c03\u7528,\u4f5c\u7528\u662f\u63a8\u9001\u6d88\u606f\u7ed9\u6d88\u8d39\u8005<\/p>\n<p>            Consumer(){}<br \/>\n            Consumer(const std::string&amp; ctag,const std::string&amp; queue_name,bool ack_flag,const ConsumerCallback&amp; cb):<br \/>\n            tag(ctag),<br \/>\n            qname(queue_name),<br \/>\n            auto_ack(ack_flag),<br \/>\n            callback(cb)<br \/>\n            {}<br \/>\n    }; <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 tag&#xff1a;\u6d88\u8d39\u8005\u7684\u552f\u4e00\u6807\u8bc6&#xff0c;\u7531\u7528\u6237\u8bbe\u7f6e<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 qname&#xff1a;\u6d88\u8d39\u8005\u8ba2\u9605\u7684\u961f\u5217<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 auto_ack&#xff1a;\u81ea\u52a8\u786e\u8ba4\u6807\u5fd7&#xff0c;\u5982\u679c\u8bbe\u7f6e\u4e3atrue&#xff0c;\u670d\u52a1\u5668\u518d\u63a8\u9001\u5b8c\u6d88\u606f\u540e\u4f1a\u76f4\u63a5\u5220\u9664\u6d88\u606f&#xff0c;\u4e0d\u7b49\u5f85\u6d88\u8d39\u8005\u7684\u786e\u8ba4\u8bf7\u6c42\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 callback&#xff1a;\u6d88\u8d39\u8005\u5bf9\u6d88\u606f\u7684\u5904\u7406\u51fd\u6570&#xff0c;\u5728\u670d\u52a1\u7aef\u5b83\u7684\u529f\u80fd\u662f\u56fa\u5b9a\u7684&#xff1a;\u5c06\u6d88\u606f\u53d1\u9001\u7ed9\u5bf9\u5e94\u7684\u5ba2\u6237\u7aef\u6d88\u8d39\u8005&#xff0c;\u56e0\u4e3a\u670d\u52a1\u5668\u7684\u6d88\u8d39\u8005\u5e76\u4e0d\u662f\u771f\u6b63\u7684\u6d88\u8d39\u8005&#xff0c;\u5ba2\u6237\u7aef\u6d88\u8d39\u8005\u624d\u662f\u771f\u6b63\u7684\u6d88\u8d39\u8005\u3002\u800c\u5ba2\u6237\u7aef\u6d88\u8d39\u8005\u7684\u6d88\u606f\u5904\u7406\u51fd\u6570\u624d\u7531\u7528\u6237\u81ea\u5df1\u5b9a\u4e49\u3002<\/p>\n<h3 id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%201-2.QueueConsumer%E7%B1%BB\">\u00a0 \u00a0 \u00a0 \u00a0 1-2.QueueConsumer\u7c7b<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8fd9\u4e2a\u7c7b\u7528\u6765\u7ba1\u7406\u4e00\u4e2a\u961f\u5217\u7684\u6240\u6709\u8ba2\u9605\u8005&#xff0c;\u00a0\u800c\u4e14\u5f53\u4e00\u6761\u6d88\u606f\u5230\u6765\u65f6&#xff0c;\u4e0d\u662f\u6240\u6709\u961f\u5217\u7684\u8ba2\u9605\u8005\u90fd\u80fd\u83b7\u5f97&#xff0c;\u53ea\u6709\u961f\u5217\u5f53\u524d\u8f6e\u8be2\u7684\u4e00\u4e2a\u6d88\u8d39\u8005\u53ef\u4ee5\u83b7\u5f97\u8fd9\u6761\u4fe1\u606f&#xff0c;\u8fd9\u79cd\u53eb\u505a\u961f\u5217\u6a21\u578b\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u00a0\u8fd8\u6709\u6bcf\u4e2a\u8ba2\u9605\u8005\u90fd\u80fd\u83b7\u5f97\u6d88\u606f\u7684\u8ba2\u9605\/\u53d1\u5e03\u6a21\u578b&#xff0c;\u73b0\u5728\u5b9e\u73b0\u7684\u662f\u961f\u5217\u6a21\u578b&#xff0c;\u9879\u76ee\u57fa\u672c\u5b8c\u6210\u540e\u4e5f\u4f1a\u5b9e\u73b0\u4e00\u4e0b\u8ba2\u9605\/\u53d1\u5e03\u6a21\u578b\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5148\u5b9e\u73b0\u4e00\u4e0b\u6784\u9020\u51fd\u6570\u548c\u6210\u5458\u53d8\u91cf&#xff1a;<\/p>\n<p>     \/\/ \u4e00\u4e2a\u961f\u5217\u7684\u6d88\u8d39\u8005\u7ba1\u7406<br \/>\n    class QueueConsumer<br \/>\n    {<br \/>\n        public:<br \/>\n            using ptr &#061; std::shared_ptr&lt;QueueConsumer&gt;;<\/p>\n<p>            QueueConsumer(const std::string&amp; qname):<br \/>\n            _qname(qname),<br \/>\n            _rr_ser(0)<br \/>\n            {}<br \/>\n        private:<br \/>\n            std::mutex _mtx;<br \/>\n            std::string _qname; \/\/ \u5f53\u524d\u7ba1\u7406\u7684\u961f\u5217\u540d\u79f0<br \/>\n            size_t _rr_ser; \/\/ \u8f6e\u8f6c\u5e8f\u53f7:\u51b3\u5b9a\u5f53\u524d\u628a\u6d88\u606f\u63a8\u9001\u7ed9\u54ea\u4e2a\u6d88\u8d39\u8005<br \/>\n            std::vector&lt;Consumer::ptr&gt; _consumers; \/\/ \u8be5\u961f\u5217\u7684\u6240\u6709\u6d88\u8d39\u8005<br \/>\n    }; <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6d88\u8d39\u8005\u7ba1\u7406\u63a5\u53e3&#xff1a;<\/p>\n<p>             \/\/ \u65b0\u589e\u6d88\u8d39\u8005<br \/>\n            Consumer::ptr create(const std::string&amp; ctag,bool ack_flag,const ConsumerCallback&amp; cb)<br \/>\n            {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                \/\/ 1.\u5224\u65ad\u6d88\u8d39\u8005\u91cd\u590d\u6dfb\u52a0<br \/>\n                for(const auto&amp; consumer:_consumers)<br \/>\n                {<br \/>\n                    if(consumer-&gt;tag &#061;&#061; ctag)<br \/>\n                        return nullptr;<br \/>\n                }<br \/>\n                \/\/ 2.\u6784\u9020\u6d88\u8d39\u8005\u5bf9\u8c61\u5e76\u6dfb\u52a0<br \/>\n                Consumer::ptr consumer &#061; std::make_shared&lt;Consumer&gt;(ctag,_qname,ack_flag,cb);<br \/>\n                _consumers.push_back(consumer);<\/p>\n<p>                return consumer;<br \/>\n            }<\/p>\n<p>            \/\/ \u79fb\u9664\u6d88\u8d39\u8005<br \/>\n            void remove(const std::string&amp; ctag)<br \/>\n            {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                for(auto it &#061; _consumers.begin();it !&#061; _consumers.end();it&#043;&#043;)<br \/>\n                {<br \/>\n                    if((*it)-&gt;tag &#061;&#061; ctag)<br \/>\n                    {<br \/>\n                        _consumers.erase(it);<br \/>\n                        return;<br \/>\n                    }<br \/>\n                }<br \/>\n            } <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u83b7\u53d6\u5f53\u524d\u8f6e\u8be2\u7684\u6d88\u8d39\u8005&#xff0c;\u51b3\u5b9a\u6d88\u606f\u7684\u53bb\u5411&#xff1a;<\/p>\n<p>             \/\/ \u83b7\u53d6\u5f53\u524d\u8f6e\u8be2\u7684\u6d88\u8d39\u8005<br \/>\n            Consumer::ptr choose()<br \/>\n            {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                if(_consumers.size() &#061;&#061; 0)<br \/>\n                    return nullptr;<br \/>\n                return _consumers[_rr_ser&#043;&#043;%_consumers.size()];;<br \/>\n            } <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u53d6\u6a21\u662f\u4e3a\u4e86\u4e0d\u4f1a\u8d8a\u754c\u8bbf\u95ee\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5176\u4ed6\u7684\u529f\u80fd\u51fd\u6570&#xff1a;<\/p>\n<p>             \/\/ \u5224\u7a7a<br \/>\n            bool empty()<br \/>\n            {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                return _consumers.empty();<br \/>\n            }<\/p>\n<p>            \/\/ \u5224\u65ad\u6d88\u8d39\u8005\u662f\u5426\u5b58\u5728<br \/>\n            bool exists(const std::string&amp; ctag)<br \/>\n            {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                for(const auto&amp; consumer:_consumers)<br \/>\n                {<br \/>\n                    if(consumer-&gt;tag &#061;&#061; ctag)<br \/>\n                        return true;<br \/>\n                }<br \/>\n                return false;<br \/>\n            }<\/p>\n<p>            \/\/ \u6e05\u7406\u6240\u6709\u6d88\u8d39\u8005<br \/>\n            void clear()<br \/>\n            {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                _consumers.clear();<br \/>\n                _rr_ser &#061; 0;<br \/>\n            } <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6790\u6784\u51fd\u6570\u8c03\u7528clear()\u63a5\u53e3&#xff0c;\u8fd9\u6837\u5f53\u961f\u5217\u88ab\u5220\u9664\u65f6&#xff0c;\u4e5f\u4f1a\u5220\u9664\u961f\u5217\u7684QueueConsumer\u5bf9\u8c61&#xff0c;\u6790\u6784\u51fd\u6570\u5c31\u81ea\u52a8\u6e05\u7406\u6570\u636e\u4e86&#xff1a;<\/p>\n<p>            ~QueueConsumer()<br \/>\n            {<br \/>\n                clear();<br \/>\n            } <\/p>\n<p>\u00a0<\/p>\n<h3 id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%20%C2%A01-3.QueueConsumerManger%E7%B1%BB\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a01-3.QueueConsumerManger\u7c7b<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8fd9\u4e2a\u7c7b\u7528\u6765\u7ba1\u7406\u670d\u52a1\u5668\u7684\u6240\u6709\u961f\u5217\u7684\u6d88\u8d39\u8005\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u57fa\u672c\u4e0a\u5c31\u662f\u5bf9class QueueConsumer\u7684\u5c01\u88c5&#xff0c;\u4f46\u662f\u5728\u961f\u5217\u6267\u884c\u81ea\u5df1\u7684\u51fd\u6570\u7684\u65f6\u5019\u4e0d\u8981\u4e0a\u9501&#xff0c;\u56e0\u4e3a\u6bcf\u4e2a\u961f\u5217\u662f\u72ec\u7acb\u7684\u3002<\/p>\n<p>     \/\/ \u6240\u6709\u961f\u5217\u7684\u6d88\u8d39\u8005\u7ba1\u7406<br \/>\n    class QueueConsumerManger<br \/>\n    {<br \/>\n        public:<br \/>\n            using ptr &#061; std::shared_ptr&lt;QueueConsumerManger&gt;;<\/p>\n<p>            QueueConsumerManger(){}<br \/>\n            \/\/ \u63d2\u5165\u4e00\u4e2a\u6d88\u8d39\u8005\u7ba1\u7406\u961f\u5217<br \/>\n            void initQueueConsumer(const std::string&amp; qname)<br \/>\n            {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                \/\/ 1.\u5224\u65ad\u91cd\u590d<br \/>\n                auto it &#061; _queue_consumers.find(qname);<br \/>\n                if(it !&#061; _queue_consumers.end())<br \/>\n                {<br \/>\n                    return;<br \/>\n                }<br \/>\n                \/\/ 2.\u6784\u9020\u5e76\u63d2\u5165<br \/>\n                QueueConsumer::ptr queueConsumer &#061; std::make_shared&lt;QueueConsumer&gt;(qname);<br \/>\n                _queue_consumers.insert(std::make_pair(qname,queueConsumer));<br \/>\n            }<\/p>\n<p>            \/\/ \u79fb\u9664\u4e00\u4e2a\u6d88\u8d39\u8005\u7ba1\u7406\u961f\u5217<br \/>\n            void destoryQueueConsumer(const std::string&amp; qname)<br \/>\n            {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                \/\/ 1.\u5224\u65ad\u5b58\u5728<br \/>\n                auto it &#061; _queue_consumers.find(qname);<br \/>\n                if(it &#061;&#061; _queue_consumers.end())<br \/>\n                {<br \/>\n                    return;<br \/>\n                }<br \/>\n                \/\/ 2.\u79fb\u9664<br \/>\n                _queue_consumers.erase(it);<br \/>\n            }<\/p>\n<p>            \/\/ \u5411\u6307\u5b9a\u961f\u5217\u65b0\u589e\u4e00\u4e2a\u6d88\u8d39\u8005<br \/>\n            Consumer::ptr create(const std::string&amp; qname,const std::string&amp; ctag,bool ack_flag,const ConsumerCallback&amp; cb)<br \/>\n            {<br \/>\n                QueueConsumer::ptr queue;<br \/>\n                {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                \/\/ 1.\u5224\u65ad\u961f\u5217\u5b58\u5728<br \/>\n                auto qit &#061; _queue_consumers.find(qname);<br \/>\n                if(qit &#061;&#061; _queue_consumers.end())<br \/>\n                {<br \/>\n                    LOG(&#034;\u6ca1\u6709\u627e\u5230\u6d88\u8d39\u8005\u7ba1\u7406\u961f\u5217 %s&#034;,qname.c_str());<br \/>\n                    return nullptr;<br \/>\n                }<br \/>\n                queue &#061; qit-&gt;second;<br \/>\n                }<br \/>\n                \/\/ 2.\u8c03\u7528\u961f\u5217\u7ba1\u7406\u7684\u63d2\u5165<br \/>\n                return queue-&gt;create(ctag,ack_flag,cb);<br \/>\n            }<\/p>\n<p>            \/\/ \u4ece\u6307\u5b9a\u961f\u5217\u4e2d\u79fb\u9664\u4e00\u4e2a\u6d88\u8d39\u8005<br \/>\n            void remove(const std::string&amp; qname,const std::string&amp; ctag)<br \/>\n            {<br \/>\n                QueueConsumer::ptr queue;<br \/>\n                {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                \/\/ 1.\u5224\u65ad\u961f\u5217\u5b58\u5728<br \/>\n                auto qit &#061; _queue_consumers.find(qname);<br \/>\n                if(qit &#061;&#061; _queue_consumers.end())<br \/>\n                {<br \/>\n                    LOG(&#034;\u6ca1\u6709\u627e\u5230\u6d88\u8d39\u8005\u7ba1\u7406\u961f\u5217 %s&#034;,qname.c_str());<br \/>\n                    return;<br \/>\n                }<br \/>\n                queue &#061; qit-&gt;second;<br \/>\n                }<br \/>\n                \/\/ \u8c03\u7528\u961f\u5217\u7ba1\u7406\u7684\u79fb\u9664<br \/>\n                queue-&gt;remove(ctag);<br \/>\n            }<\/p>\n<p>            \/\/ \u83b7\u53d6\u4e00\u4e2a\u6d88\u8d39\u8005\u7ba1\u7406\u961f\u5217\u7684\u5f53\u524d\u8f6e\u8be2\u6d88\u8d39\u8005<br \/>\n            Consumer::ptr choose(const std::string&amp; qname)<br \/>\n            {<br \/>\n                QueueConsumer::ptr queue;<br \/>\n                {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                \/\/ 1.\u5224\u65ad\u961f\u5217\u5b58\u5728<br \/>\n                auto qit &#061; _queue_consumers.find(qname);<br \/>\n                if(qit &#061;&#061; _queue_consumers.end())<br \/>\n                {<br \/>\n                    LOG(&#034;\u6ca1\u6709\u627e\u5230\u6d88\u8d39\u8005\u7ba1\u7406\u961f\u5217 %s&#034;,qname.c_str());<br \/>\n                    return nullptr;<br \/>\n                }<br \/>\n                queue &#061; qit-&gt;second;<br \/>\n                }<br \/>\n                return queue-&gt;choose();<br \/>\n            }<\/p>\n<p>            \/\/ \u5224\u7a7a<br \/>\n            bool empty(const std::string&amp; qname)<br \/>\n            {<br \/>\n                QueueConsumer::ptr queue;<br \/>\n                {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                \/\/ 1.\u5224\u65ad\u961f\u5217\u5b58\u5728<br \/>\n                auto qit &#061; _queue_consumers.find(qname);<br \/>\n                if(qit &#061;&#061; _queue_consumers.end())<br \/>\n                {<br \/>\n                    LOG(&#034;\u6ca1\u6709\u627e\u5230\u6d88\u8d39\u8005\u7ba1\u7406\u961f\u5217 %s&#034;,qname.c_str());<br \/>\n                    return false;<br \/>\n                }<br \/>\n                queue &#061; qit-&gt;second;<br \/>\n                }<br \/>\n                return queue-&gt;empty();<br \/>\n            }<\/p>\n<p>            \/\/ \u5224\u65ad\u67d0\u4e2a\u961f\u5217\u7684\u67d0\u4e2a\u6d88\u8d39\u8005\u662f\u5426\u5b58\u5728<br \/>\n            bool exists(const std::string&amp; qname,const std::string&amp; ctag)<br \/>\n            {<br \/>\n                QueueConsumer::ptr queue;<br \/>\n                {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                \/\/ 1.\u5224\u65ad\u961f\u5217\u5b58\u5728<br \/>\n                auto qit &#061; _queue_consumers.find(qname);<br \/>\n                if(qit &#061;&#061; _queue_consumers.end())<br \/>\n                {<br \/>\n                    LOG(&#034;\u6ca1\u6709\u627e\u5230\u6d88\u8d39\u8005\u7ba1\u7406\u961f\u5217 %s&#034;,qname.c_str());<br \/>\n                    return false;<br \/>\n                }<br \/>\n                queue &#061; qit-&gt;second;<br \/>\n                }<br \/>\n                return queue-&gt;exists(ctag);<br \/>\n            }<\/p>\n<p>            \/\/ \u6e05\u7406<br \/>\n            void clear()<br \/>\n            {<br \/>\n                std::unique_lock&lt;std::mutex&gt; lock(_mtx);<br \/>\n                _queue_consumers.clear();<br \/>\n            }<\/p>\n<p>            size_t size()<br \/>\n            {<br \/>\n                return _queue_consumers.size();<br \/>\n            }<br \/>\n        private:<br \/>\n            std::unordered_map&lt;std::string,QueueConsumer::ptr&gt; _queue_consumers;<br \/>\n            std::mutex _mtx;<br \/>\n    }; <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<h2 id=\"%E7%AC%AC%E4%BA%8C%E8%8A%82%EF%BC%9A%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95\">\u7b2c\u4e8c\u8282&#xff1a;\u5355\u5143\u6d4b\u8bd5<\/h2>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6253\u5f00mqtest\u76ee\u5f55&#xff0c;\u521b\u5efamq_consumer_test.cc&#xff0c;\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u8fdb\u884c\u6d4b\u8bd5&#xff1a;<\/p>\n<p> #include &#034;..\/mqserver\/mq_consumer.hpp&#034;<br \/>\n#include &lt;gtest\/gtest.h&gt;<br \/>\n#include &lt;iostream&gt;<br \/>\n#include &lt;unordered_map&gt;<\/p>\n<p>zd::QueueConsumerManger::ptr qcmp;<br \/>\nvoid cb(const std::string,const zd::BasicProperties*,const std::string){};<br \/>\n\/\/ \u5168\u5c40\u6d4b\u8bd5\u5957\u4ef6&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\/\/ \u81ea\u5df1\u521d\u59cb\u5316\u81ea\u5df1\u7684\u73af\u5883&#xff0c;\u4f7f\u4e0d\u540c\u5355\u5143\u6d4b\u8bd5\u4e4b\u95f4\u89e3\u8026<br \/>\nclass ConsumerTest :public testing::Environment<br \/>\n{<br \/>\npublic:<br \/>\n    \/\/ \u5168\u90e8\u5355\u5143\u6d4b\u8bd5\u4e4b\u524d\u8c03\u7528\u4e00\u6b21<br \/>\n    virtual void SetUp() override<br \/>\n    {<br \/>\n        \/\/ std::cout &lt;&lt; &#034;\u5355\u5143\u6d4b\u8bd5\u6267\u884c\u524d\u7684\u73af\u5883\u521d\u59cb\u5316&#034; &lt;&lt; std::endl;<br \/>\n        qcmp &#061; std::make_shared&lt;zd::QueueConsumerManger&gt;();<br \/>\n    }   <\/p>\n<p>    \/\/ \u5168\u90e8\u5355\u5143\u6d4b\u8bd5\u4e4b\u540e\u8c03\u7528\u4e00\u6b21<br \/>\n    virtual void TearDown() override<br \/>\n    {<br \/>\n        \/\/ std::cout &lt;&lt; &#034;\u5355\u5143\u6d4b\u8bd5\u6267\u884c\u540e\u7684\u73af\u5883\u6e05\u7406&#034; &lt;&lt; std::endl;<br \/>\n        \/\/ emp-&gt;clear();<br \/>\n    }<br \/>\n};<\/p>\n<p>\/\/ \u5355\u5143\u6d4b\u8bd5<br \/>\n\/\/ \u6d4b\u8bd5\u540d\u79f0\u4e0e\u7c7b\u540d\u79f0\u76f8\u540c&#xff0c;\u5219\u4f1a\u5148\u8c03\u7528SetUp<br \/>\n\/\/ \u6d4b\u8bd5\u961f\u5217\u7684\u65b0\u589e\u548c\u79fb\u9664<br \/>\nTEST(ConsumerTest,ConsumerTest_test1_Test)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u5355\u5143\u6d4b\u8bd5-1&#034; &lt;&lt; std::endl;<br \/>\n    \/\/ \u65b0\u589e\u961f\u5217<br \/>\n    qcmp-&gt;initQueueConsumer(&#034;q1&#034;);<br \/>\n    ASSERT_EQ(qcmp-&gt;size(),1);<br \/>\n    qcmp-&gt;initQueueConsumer(&#034;q2&#034;);<br \/>\n    ASSERT_EQ(qcmp-&gt;size(),2);<br \/>\n    qcmp-&gt;initQueueConsumer(&#034;q3&#034;);<br \/>\n    ASSERT_EQ(qcmp-&gt;size(),3);<br \/>\n    qcmp-&gt;initQueueConsumer(&#034;q4&#034;);<br \/>\n    ASSERT_EQ(qcmp-&gt;size(),4);<br \/>\n    qcmp-&gt;initQueueConsumer(&#034;q5&#034;);<br \/>\n    ASSERT_EQ(qcmp-&gt;size(),5);<br \/>\n    qcmp-&gt;initQueueConsumer(&#034;q1&#034;);<br \/>\n    ASSERT_EQ(qcmp-&gt;size(),5);<\/p>\n<p>    \/\/ \u79fb\u9664\u961f\u5217<br \/>\n    qcmp-&gt;destoryQueueConsumer(&#034;q2&#034;);<br \/>\n    ASSERT_EQ(qcmp-&gt;size(),4);<br \/>\n    qcmp-&gt;destoryQueueConsumer(&#034;q6&#034;);<br \/>\n    ASSERT_EQ(qcmp-&gt;size(),4); <\/p>\n<p>    \/\/ q1 q3 q4 q5<br \/>\n}<br \/>\n\/\/ \u6d4b\u8bd5\u6d88\u8d39\u8005\u7684\u65b0\u589e\u548c\u79fb\u9664<br \/>\nTEST(ConsumerTest,ConsumerTest_test2_Test)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u5355\u5143\u6d4b\u8bd5-2&#034; &lt;&lt; std::endl;<br \/>\n    \/\/ \u5411\u961f\u5217\u65b0\u589e\u6d88\u8d39\u8005<br \/>\n    qcmp-&gt;create(&#034;q1&#034;,&#034;consumer-1&#034;,false,cb);<br \/>\n    qcmp-&gt;create(&#034;q1&#034;,&#034;consumer-2&#034;,false,cb);<br \/>\n    qcmp-&gt;create(&#034;q1&#034;,&#034;consumer-3&#034;,false,cb);<br \/>\n    qcmp-&gt;create(&#034;q1&#034;,&#034;consumer-4&#034;,false,cb);<br \/>\n    qcmp-&gt;create(&#034;q1&#034;,&#034;consumer-5&#034;,false,cb);<br \/>\n    ASSERT_EQ(qcmp-&gt;exists(&#034;q1&#034;,&#034;consumer-1&#034;),true);<br \/>\n    ASSERT_EQ(qcmp-&gt;exists(&#034;q1&#034;,&#034;consumer-6&#034;),false);<\/p>\n<p>    \/\/ \u4ece\u961f\u5217\u79fb\u9664\u6d88\u8d39\u8005<br \/>\n    qcmp-&gt;remove(&#034;q1&#034;,&#034;consumer-2&#034;);<br \/>\n    ASSERT_EQ(qcmp-&gt;exists(&#034;q1&#034;,&#034;consumer-2&#034;),false);<br \/>\n    ASSERT_EQ(qcmp-&gt;exists(&#034;q2&#034;,&#034;consumer-2&#034;),false);  \/\/ q2\u4e4b\u524d\u5df2\u7ecf\u88ab\u79fb\u9664\u4e86<br \/>\n    \/\/ q1:c1 c3 c4 c5<br \/>\n}<br \/>\n\/\/ \u6d4b\u8bd5\u5f53\u524d\u8f6e\u8be2\u63a5\u53e3<br \/>\nTEST(ConsumerTest,ConsumerTest_test3_Test)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u5355\u5143\u6d4b\u8bd5-3&#034; &lt;&lt; std::endl;<br \/>\n    zd::Consumer::ptr cp1 &#061; qcmp-&gt;choose(&#034;q1&#034;);<br \/>\n    zd::Consumer::ptr cp2 &#061; qcmp-&gt;choose(&#034;q1&#034;);<br \/>\n    zd::Consumer::ptr cp3 &#061; qcmp-&gt;choose(&#034;q1&#034;);<br \/>\n    zd::Consumer::ptr cp4 &#061; qcmp-&gt;choose(&#034;q1&#034;);<br \/>\n    std::cout &lt;&lt; std::endl;<br \/>\n    std::cout &lt;&lt; cp1-&gt;tag &lt;&lt; &#034; &#034; &lt;&lt; cp2-&gt;tag &lt;&lt; &#034; &#034; &lt;&lt; cp3-&gt;tag &lt;&lt; &#034; &#034; &lt;&lt; cp4-&gt;tag &lt;&lt; std::endl;<br \/>\n    std::cout &lt;&lt; std::endl;<\/p>\n<p>    zd::Consumer::ptr cp5 &#061; qcmp-&gt;choose(&#034;q3&#034;);<br \/>\n    ASSERT_EQ(cp5.get(),nullptr);<br \/>\n}<br \/>\n\/\/ \u5355\u5143\u6d4b\u8bd5\u5168\u90e8\u7ed3\u675f\u540e\u8c03\u7528TearDown<\/p>\n<p>\/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nint main(int argc,char** argv)<br \/>\n{<br \/>\n    testing::InitGoogleTest(&amp;argc,argv);<\/p>\n<p>    testing::AddGlobalTestEnvironment(new ConsumerTest); \/\/ \u6ce8\u518cTest\u7684\u6240\u6709\u5355\u5143\u6d4b\u8bd5<\/p>\n<p>    if(RUN_ALL_TESTS() !&#061; 0) \/\/ \u8fd0\u884c\u6240\u6709\u5355\u5143\u6d4b\u8bd5<br \/>\n    {<br \/>\n        printf(&#034;\u5355\u5143\u6d4b\u8bd5\u5931\u8d25&#xff01;\\\\n&#034;);<br \/>\n    }<br \/>\n    return 0;<br \/>\n} <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u7f16\u8bd1&#xff1a;<\/p>\n<p> mq_consumer_test:mq_consumer_test.cc<br \/>\ng&#043;&#043; -std&#061;c&#043;&#043;14 $^ -o $&#064; -lgtest -lprotobuf <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6267\u884c\u7ed3\u679c&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"266\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418150227-680269833d52a.png\" width=\"395\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6ca1\u6709\u9519\u8bef&#xff0c;\u6253\u5370\u4e5f\u7b26\u5408\u9884\u671f\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u670d\u52a1\u5668\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757\u5c31\u5b8c\u6210\u4e86\u3002<\/p>\n<\/p>\n<h2 id=\"%E4%B8%8B%E6%9C%9F%E9%A2%84%E5%91%8A%EF%BC%9A\" style=\"background-color:transparent\">\u4e0b\u671f\u9884\u544a&#xff1a;<\/h2>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5b8c\u6210\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757\u4e4b\u540e&#xff0c;\u4e0b\u4e00\u4e2a\u8981\u5b8c\u6210\u7684\u662f\u4fe1\u9053\u7ba1\u7406\u6a21\u5757\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5bf9\u4e8e\u670d\u52a1\u5668\u6765\u8bf4&#xff0c;\u4e00\u4e2a\u4fe1\u9053\u5c31\u53ef\u4ee5\u662f\u4e00\u4e2a\u6d88\u8d39\u8005\u3002\u5982\u679c\u5ba2\u6237\u7aef\u521b\u5efa\u4e86\u4e00\u4e2a\u4fe1\u9053(c-1)&#xff0c;\u5ba2\u6237\u7aef\u5c31\u4f1a\u53d1\u9001\u521b\u5efa\u4fe1\u9053\u7684\u8bf7\u6c42\u7ed9\u670d\u52a1\u5668&#xff0c;\u670d\u52a1\u5668\u6536\u5230\u8bf7\u6c42\u540e\u4e5f\u4f1a\u521b\u5efa\u4e00\u4e2a\u5bf9\u5e94\u7684\u4fe1\u9053(c-1&#039;)\u3002\u5f53\u5ba2\u6237\u7aef\u4f7f\u7528\u4fe1\u9053\u8fdb\u884c\u8ba2\u9605\u7684\u65f6\u5019&#xff0c;\u670d\u52a1\u5668\u7684\u5bf9\u5e94\u4fe1\u9053\u5c31\u4f1a\u627f\u62c5\u6d88\u8d39\u8005\u7684\u89d2\u8272&#xff0c;\u670d\u52a1\u5668\u4f1a\u628a\u6d88\u606f\u63a8\u9001\u7ed9\u8fd9\u4e2a\u4fe1\u9053&#xff0c;\u8fd9\u4e2a\u4fe1\u9053\u518d\u628a\u6d88\u606f\u63a8\u9001\u7ed9\u5ba2\u6237\u7aef\u7684\u4fe1\u9053\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4ee5\u4e0a\u8fc7\u7a0b\u4e2d&#xff0c;\u6d88\u606f\u90fd\u88ab\u63a8\u9001\u7ed9\u4e86\u670d\u52a1\u5668\u7684c-1&#039;&#xff0c;\u6240\u4ee5\u5bf9\u4e8e\u670d\u52a1\u5668\u6765\u8bf4&#xff0c;c-1&#039;\u624d\u662f\u6d88\u8d39\u8005&#xff0c;\u800c\u4e0d\u662f\u771f\u6b63\u4f7f\u7528\u6d88\u606f\u7684\u5ba2\u6237\u7aef\u4fe1\u9053c-1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb780\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf24\u6b21\u3002\u670d\u52a1\u5668\u7684\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757\u5728mqserver\u76ee\u5f55\u4e0b\u5b9e\u73b0\u3002<\/p>\n","protected":false},"author":2,"featured_media":16591,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,1154,1155],"topic":[],"class_list":["post-16592","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-rabbit","tag-1155"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7b2c\u5341\u7ae0\uff1a\u670d\u52a1\u5668\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757 - \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\/16592.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7b2c\u5341\u7ae0\uff1a\u670d\u52a1\u5668\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb780\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf24\u6b21\u3002\u670d\u52a1\u5668\u7684\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757\u5728mqserver\u76ee\u5f55\u4e0b\u5b9e\u73b0\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/16592.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T15:02:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418150227-680269833d52a.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=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/16592.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/16592.html\",\"name\":\"\u7b2c\u5341\u7ae0\uff1a\u670d\u52a1\u5668\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T15:02:28+00:00\",\"dateModified\":\"2025-04-18T15:02:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/16592.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/16592.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/16592.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7b2c\u5341\u7ae0\uff1a\u670d\u52a1\u5668\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757\"}]},{\"@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":"\u7b2c\u5341\u7ae0\uff1a\u670d\u52a1\u5668\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757 - \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\/16592.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7b2c\u5341\u7ae0\uff1a\u670d\u52a1\u5668\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb780\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf24\u6b21\u3002\u670d\u52a1\u5668\u7684\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757\u5728mqserver\u76ee\u5f55\u4e0b\u5b9e\u73b0\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/16592.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T15:02:28+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418150227-680269833d52a.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/16592.html","url":"https:\/\/www.wsisp.com\/helps\/16592.html","name":"\u7b2c\u5341\u7ae0\uff1a\u670d\u52a1\u5668\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T15:02:28+00:00","dateModified":"2025-04-18T15:02:28+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/16592.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/16592.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/16592.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7b2c\u5341\u7ae0\uff1a\u670d\u52a1\u5668\u6d88\u8d39\u8005\u7ba1\u7406\u6a21\u5757"}]},{"@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\/16592","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=16592"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/16592\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/16591"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=16592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=16592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=16592"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=16592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}