{"id":102509,"date":"2026-09-08T23:17:04","date_gmt":"2026-09-08T15:17:04","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/102509.html"},"modified":"2026-09-08T23:17:04","modified_gmt":"2026-09-08T15:17:04","slug":"springcloud-%e9%93%b6%e8%a1%8c%e4%bf%9d%e9%99%a9%e4%b8%9a%e5%8a%a1-%e5%a4%96%e9%83%a8%e8%b0%83%e7%94%a8%e6%8e%a5%e5%8f%a3%e5%b9%82%e7%ad%89%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/102509.html","title":{"rendered":"SpringCloud \u94f6\u884c\u4fdd\u9669\u4e1a\u52a1 \u5916\u90e8\u8c03\u7528\u63a5\u53e3\u5e42\u7b49\u5b9e\u6218"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E6%96%B9%E6%A1%88%E9%80%89%E5%9E%8B%EF%BC%88%E9%93%B6%E8%A1%8C%E4%BF%9D%E9%99%A9%E7%94%9F%E4%BA%A7%E5%B8%B8%E7%94%A8%EF%BC%89-toc\" style=\"margin-left:40px\">\u65b9\u6848\u9009\u578b&#xff08;\u94f6\u884c\u4fdd\u9669\u751f\u4ea7\u5e38\u7528&#xff09;<\/p>\n<p id=\"%E6%8A%80%E6%9C%AF%E6%A0%88-toc\" style=\"margin-left:40px\">\u6280\u672f\u6808<\/p>\n<p id=\"%E5%AE%9E%E6%88%98%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81-toc\" style=\"margin-left:0px\">\u5b9e\u6218\u5b8c\u6574\u4ee3\u7801<\/p>\n<p id=\"1.%20%E5%B9%82%E7%AD%89%E6%95%B0%E6%8D%AE%E5%BA%93%E8%A1%A8%EF%BC%88%E9%87%91%E8%9E%8D%E5%BF%85%E5%AD%98%EF%BC%8C%E5%85%9C%E5%BA%95%EF%BC%89-toc\" style=\"margin-left:40px\">1. \u5e42\u7b49\u6570\u636e\u5e93\u8868&#xff08;\u91d1\u878d\u5fc5\u5b58&#xff0c;\u515c\u5e95&#xff09;<\/p>\n<p id=\"2.%20%E5%B9%82%E7%AD%89%E7%8A%B6%E6%80%81%E6%9E%9A%E4%B8%BE-toc\" style=\"margin-left:40px\">2. \u5e42\u7b49\u72b6\u6001\u679a\u4e3e<\/p>\n<p id=\"3.%20%E8%87%AA%E5%AE%9A%E4%B9%89%E6%B3%A8%E8%A7%A3%EF%BC%9A%40Idempotent%20%E6%96%B9%E4%BE%BF%20AOP%20%E5%88%87%E9%9D%A2%E5%AE%9E%E7%8E%B0%E5%B9%82%E7%AD%89%EF%BC%88%E9%93%B6%E8%A1%8C%E4%BF%9D%E9%99%A9%E4%B8%9A%E5%8A%A1%EF%BC%89-toc\" style=\"margin-left:40px\">3. \u81ea\u5b9a\u4e49\u6ce8\u89e3&#xff1a;&#064;Idempotent \u65b9\u4fbf AOP \u5207\u9762\u5b9e\u73b0\u5e42\u7b49&#xff08;\u94f6\u884c\u4fdd\u9669\u4e1a\u52a1&#xff09;<\/p>\n<p id=\"4.%20AOP%20%E5%88%87%E9%9D%A2%E6%A0%B8%E5%BF%83%E5%AE%9E%E7%8E%B0%EF%BC%88%E5%B9%82%E7%AD%89%E6%A0%B8%E5%BF%83%E9%80%BB%E8%BE%91%EF%BC%89-toc\" style=\"margin-left:40px\">4. AOP \u5207\u9762\u6838\u5fc3\u5b9e\u73b0&#xff08;\u5e42\u7b49\u6838\u5fc3\u903b\u8f91&#xff09;<\/p>\n<p id=\"5.%20%E5%9C%BA%E6%99%AF%E4%B8%80%EF%BC%9A%E6%88%91%E6%96%B9%E6%9C%8D%E5%8A%A1%20Feign%20%E8%B0%83%E7%94%A8%E9%93%B6%E8%A1%8C%E5%A4%96%E9%83%A8%E6%94%AF%E4%BB%98%E6%8E%A5%E5%8F%A3%EF%BC%88%E9%93%B6%E8%A1%8C%E4%BF%9D%E9%99%A9%E6%94%AF%E4%BB%98%EF%BC%89-toc\" style=\"margin-left:40px\">5. \u573a\u666f\u4e00&#xff1a;\u6211\u65b9\u670d\u52a1 Feign \u8c03\u7528\u94f6\u884c\u5916\u90e8\u652f\u4ed8\u63a5\u53e3&#xff08;\u94f6\u884c\u4fdd\u9669\u652f\u4ed8&#xff09;<\/p>\n<p id=\"6.%20%E5%9C%BA%E6%99%AF%E4%BA%8C%EF%BC%9A%E9%93%B6%E8%A1%8C%E5%BC%82%E6%AD%A5%E5%9B%9E%E8%B0%83%E6%88%91%E6%96%B9%E4%BF%9D%E9%99%A9%E6%8E%A5%E5%8F%A3%EF%BC%88%E9%93%B6%E8%A1%8C%E5%9B%9E%E8%B0%83%20Controller%EF%BC%89-toc\" style=\"margin-left:40px\">6. \u573a\u666f\u4e8c&#xff1a;\u94f6\u884c\u5f02\u6b65\u56de\u8c03\u6211\u65b9\u4fdd\u9669\u63a5\u53e3&#xff08;\u94f6\u884c\u56de\u8c03 Controller&#xff09;<\/p>\n<p id=\"7.%20%E5%9C%BA%E6%99%AF%E4%B8%89%EF%BC%9ARocketMQ%20%E6%B6%88%E8%B4%B9%E4%BF%9D%E9%99%A9%E6%8A%95%E4%BF%9D%E6%B6%88%E6%81%AF%EF%BC%88%E9%98%B2%E6%AD%A2%20MQ%20%E9%87%8D%E5%A4%8D%E6%B6%88%E8%B4%B9%EF%BC%89-toc\" style=\"margin-left:40px\">7. \u573a\u666f\u4e09&#xff1a;RocketMQ \u6d88\u8d39\u4fdd\u9669\u6295\u4fdd\u6d88\u606f&#xff08;\u9632\u6b62 MQ \u91cd\u590d\u6d88\u8d39&#xff09;<\/p>\n<p id=\"8.%20%E5%85%B3%E9%94%AE%E9%87%91%E8%9E%8D%E5%9D%91%E7%82%B9%EF%BC%88%E9%93%B6%E8%A1%8C%E4%BF%9D%E9%99%A9%E4%B8%9A%E5%8A%A1%E9%87%8D%E7%82%B9%EF%BC%89-toc\" style=\"margin-left:40px\">8. \u5173\u952e\u91d1\u878d\u5751\u70b9&#xff08;\u94f6\u884c\u4fdd\u9669\u4e1a\u52a1\u91cd\u70b9&#xff09;<\/p>\n<p id=\"%E5%9D%91%201%EF%BC%9A%E8%B0%83%E7%94%A8%E5%A4%96%E9%83%A8%E9%93%B6%E8%A1%8C%E6%8E%A5%E5%8F%A3%E6%88%90%E5%8A%9F%EF%BC%8C%E6%9C%AC%E5%9C%B0%E6%9C%8D%E5%8A%A1%E5%AE%95%E6%9C%BA-toc\" style=\"margin-left:80px\">\u5751 1&#xff1a;\u8c03\u7528\u5916\u90e8\u94f6\u884c\u63a5\u53e3\u6210\u529f&#xff0c;\u672c\u5730\u670d\u52a1\u5b95\u673a<\/p>\n<p id=\"%E5%9D%91%202%EF%BC%9A%E9%93%B6%E8%A1%8C%E6%8E%A5%E5%8F%A3%E6%98%AF%E7%BB%93%E6%9E%9C%E6%9C%AA%E7%9F%A5%EF%BC%88%E7%BD%91%E7%BB%9C%E8%B6%85%E6%97%B6%EF%BC%89-toc\" style=\"margin-left:80px\">\u5751 2&#xff1a;\u94f6\u884c\u63a5\u53e3\u662f\u7ed3\u679c\u672a\u77e5&#xff08;\u7f51\u7edc\u8d85\u65f6&#xff09;<\/p>\n<p id=\"%E5%9D%91%203%EF%BC%9A%E5%B9%82%E7%AD%89%20key%20%E4%B8%8D%E8%A6%81%E7%94%A8%20requestId%EF%BC%8C%E7%BD%91%E5%85%B3%E9%87%8D%E8%AF%95%20requestId%20%E4%BC%9A%E5%8F%98-toc\" style=\"margin-left:80px\">\u5751 3&#xff1a;\u5e42\u7b49 key \u4e0d\u8981\u7528 requestId&#xff0c;\u7f51\u5173\u91cd\u8bd5 requestId \u4f1a\u53d8<\/p>\n<p id=\"%E5%9D%91%204%EF%BC%9A%E9%94%81%E6%97%B6%E9%97%B4%E4%B8%8D%E8%83%BD%E5%A4%AA%E7%9F%AD%EF%BC%8C%E9%93%B6%E8%A1%8C%E5%A4%96%E9%83%A8%E6%8E%A5%E5%8F%A3%E6%9C%89%E6%97%B6%E5%80%99%E6%85%A2%EF%BC%8C%E5%87%A0%E5%8D%81%E7%A7%92%E6%89%8D%E8%BF%94%E5%9B%9E-toc\" style=\"margin-left:80px\">\u5751 4&#xff1a;\u9501\u65f6\u95f4\u4e0d\u80fd\u592a\u77ed&#xff0c;\u94f6\u884c\u5916\u90e8\u63a5\u53e3\u6709\u65f6\u5019\u6162&#xff0c;\u51e0\u5341\u79d2\u624d\u8fd4\u56de<\/p>\n<p id=\"%E5%9D%91%205%EF%BC%9A%E5%A4%B1%E8%B4%A5%E7%8A%B6%E6%80%81%E8%A6%81%E5%85%81%E8%AE%B8%E9%87%8D%E8%AF%95-toc\" style=\"margin-left:80px\">\u5751 5&#xff1a;\u5931\u8d25\u72b6\u6001\u8981\u5141\u8bb8\u91cd\u8bd5<\/p>\n<p id=\"9.%20%E9%85%8D%E5%A5%97%EF%BC%9A%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E8%A1%A5%E5%81%BF%EF%BC%88%E9%87%91%E8%9E%8D%E7%94%9F%E4%BA%A7%E5%BF%85%E5%A4%87%EF%BC%89-toc\" style=\"margin-left:40px\">9. \u914d\u5957&#xff1a;\u5b9a\u65f6\u4efb\u52a1\u8865\u507f&#xff08;\u91d1\u878d\u751f\u4ea7\u5fc5\u5907&#xff09;<\/p>\n<p id=\"10.%20%E5%85%B6%E4%BB%96%E8%A1%A5%E5%85%85-toc\" style=\"margin-left:40px\">10. \u5176\u4ed6\u8865\u5145<\/p>\n<p id=\"%E6%95%B4%E4%BD%93%E6%B5%81%E7%A8%8B%E6%80%BB%E7%BB%93-toc\" style=\"margin-left:40px\">\u6574\u4f53\u6d41\u7a0b\u603b\u7ed3<\/p>\n<hr id=\"hr-toc\" \/>\n<p>\u4e1a\u52a1\u80cc\u666f&#xff1a;\u94f6\u884c\u4fdd\u9669\u573a\u666f&#xff0c;\u8c03\u7528\u94f6\u884c\u5916\u90e8\u652f\u4ed8 \/ \u5bf9\u8d26 \/ \u6295\u4fdd\u56de\u6267\u63a5\u53e3&#xff0c;\u7f51\u7edc\u6296\u52a8\u3001\u91cd\u8bd5\u3001MQ \u91cd\u590d\u6d88\u8d39\u3001\u524d\u7aef\u91cd\u590d\u63d0\u4ea4&#xff0c;\u4f1a\u5bfc\u81f4&#xff1a;\u91cd\u590d\u6263\u6b3e\u3001\u91cd\u590d\u6295\u4fdd\u3001\u91cd\u590d\u751f\u6210\u4fdd\u5355\u3001\u91cd\u590d\u5bf9\u8d26\u3002 \u6838\u5fc3\u75db\u70b9&#xff1a;\u5916\u90e8\u94f6\u884c\u63a5\u53e3\u4e0d\u4fdd\u8bc1\u53ea\u56de\u8c03\u4e00\u6b21&#xff1b;\u6211\u65b9\u670d\u52a1\u91cd\u8bd5&#xff1b;\u7f51\u5173\u91cd\u8bd5&#xff1b;MQ \u91cd\u590d\u6295\u9012\u3002 \u5e42\u7b49\u76ee\u6807&#xff1a;\u540c\u4e00\u4e2a\u4e1a\u52a1\u8bf7\u6c42&#xff0c;\u65e0\u8bba\u8c03\u7528 N \u6b21&#xff0c;\u4e1a\u52a1\u7ed3\u679c\u53ea\u751f\u6548\u4e00\u6b21&#xff0c;\u8fd4\u56de\u76f8\u540c\u54cd\u5e94\u3002<\/p>\n<h3 id=\"%E6%96%B9%E6%A1%88%E9%80%89%E5%9E%8B%EF%BC%88%E9%93%B6%E8%A1%8C%E4%BF%9D%E9%99%A9%E7%94%9F%E4%BA%A7%E5%B8%B8%E7%94%A8%EF%BC%89\">\u65b9\u6848\u9009\u578b&#xff08;\u94f6\u884c\u4fdd\u9669\u751f\u4ea7\u5e38\u7528&#xff09;<\/h3>\n<table>\n<tr>\u65b9\u6848\u9002\u7528\u573a\u666f\u94f6\u884c\u4fdd\u9669\u662f\u5426\u63a8\u8350<\/tr>\n<tbody>\n<tr>\n<td>\u6570\u636e\u5e93\u552f\u4e00\u7d22\u5f15<\/td>\n<td>\u65b0\u589e\u7c7b&#xff08;\u4fdd\u5355\u3001\u6d41\u6c34&#xff09;<\/td>\n<td>\u2705 \u57fa\u7840\u515c\u5e95<\/td>\n<\/tr>\n<tr>\n<td>Token \u4ee4\u724c\u673a\u5236<\/td>\n<td>\u524d\u7aef\u63d0\u4ea4\u3001\u7f51\u5173\u5165\u53e3<\/td>\n<td>\u2705 \u6295\u4fdd\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td>\u4e1a\u52a1\u552f\u4e00\u952e &#043; Redis \u5e42\u7b49\u9501&#xff08;\u91cd\u70b9\u5b9e\u6218&#xff09;<\/td>\n<td>\u8c03\u7528\u5916\u90e8\u94f6\u884c\u63a5\u53e3\u3001MQ \u6d88\u8d39\u3001\u56de\u8c03\u63a5\u53e3<\/td>\n<td>\u2b50\u2b50\u2b50\u2b50\u2b50 \u672c\u6848\u4f8b\u4e3b\u65b9\u6848<\/td>\n<\/tr>\n<tr>\n<td>\u72b6\u6001\u673a\u6d41\u8f6c<\/td>\n<td>\u8ba2\u5355 \/ \u4fdd\u5355\u72b6\u6001\u53d8\u66f4<\/td>\n<td>\u2705 \u4fdd\u5355\u72b6\u6001\u6d41\u8f6c\u6821\u9a8c<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u5e93\u4e50\u89c2\u9501<\/td>\n<td>\u66f4\u65b0\u64cd\u4f5c<\/td>\n<td>\u2705 \u4fdd\u5355\u66f4\u65b0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u94f6\u884c\u5916\u90e8\u63a5\u53e3\u573a\u666f&#xff1a;\u6211\u65b9\u4e3b\u52a8\u8c03\u7528\u94f6\u884c\u63a5\u53e3&#xff1b;\u94f6\u884c\u5f02\u6b65\u56de\u8c03\u6211\u65b9\u63a5\u53e3\u3002\u4e24\u5957\u90fd\u8981\u505a\u5e42\u7b49\u3002 \u5e42\u7b49 Key&#xff1a;\u4e1a\u52a1\u5168\u5c40\u552f\u4e00\u6807\u8bc6&#xff0c;\u4e0d\u80fd\u7528 requestId&#xff08;\u7f51\u5173\u4f1a\u53d8&#xff09;&#xff0c;\u8981\u7528\u4e1a\u52a1\u53f7&#xff1a;\u6295\u4fdd\u5355\u53f7policyNo\u3001\u4ea4\u6613\u6d41\u6c34\u53f7tradeNo\u3002<\/p>\n<p>\u5e42\u7b49\u6838\u5fc3\u903b\u8f91<\/p>\n<li>\u8bf7\u6c42\u8fdb\u6765&#xff0c;\u62ff\u5230\u4e1a\u52a1\u552f\u4e00\u7f16\u53f7 tradeNo\/policyNo<\/li>\n<li>\u5148\u67e5\u5e42\u7b49\u8bb0\u5f55&#xff1a;\n<ul>\n<li>\u5982\u679c\u5df2\u5904\u7406\u5b8c\u6210&#xff1a;\u76f4\u63a5\u8fd4\u56de\u5386\u53f2\u7ed3\u679c&#xff0c;\u4e0d\u518d\u8c03\u7528\u94f6\u884c\u5916\u90e8\u63a5\u53e3<\/li>\n<li>\u5982\u679c\u5904\u7406\u4e2d&#xff1a;\u8fd4\u56de\u5904\u7406\u4e2d&#xff0c;\u62d2\u7edd\u91cd\u590d\u6267\u884c\u4e1a\u52a1<\/li>\n<li>\u5982\u679c\u4e0d\u5b58\u5728&#xff1a;\u62a2\u5360\u5e42\u7b49\u6807\u8bb0&#xff0c;\u6267\u884c\u4e1a\u52a1&#xff08;\u8c03\u7528\u94f6\u884c\u5916\u90e8\u63a5\u53e3&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>\u4e1a\u52a1\u6210\u529f&#xff1a;\u6807\u8bb0\u5e42\u7b49\u4e3a\u5b8c\u6210&#xff0c;\u7f13\u5b58\u8fd4\u56de\u7ed3\u679c<\/li>\n<li>\u4e1a\u52a1\u5931\u8d25&#xff1a;\u5220\u9664 \/ \u7f6e\u4e3a\u5931\u8d25&#xff0c;\u5141\u8bb8\u540e\u7eed\u91cd\u8bd5<\/li>\n<p>\u26a0\ufe0f\u91cd\u70b9&#xff1a;\u8c03\u7528\u7b2c\u4e09\u65b9\u94f6\u884c\u63a5\u53e3\u4e00\u5b9a\u8981\u9632\u56de\u6eda\u6f0f\u6d1e&#xff1a;\u62a2\u5360\u4e86\u5e42\u7b49\u6807\u8bb0&#xff0c;\u4f46\u662f\u8c03\u7528\u94f6\u884c\u63a5\u53e3\u6210\u529f&#xff0c;\u672c\u5730\u670d\u52a1\u5b95\u673a&#xff0c;\u4e0d\u80fd\u628a\u5e42\u7b49 key \u5220\u6389&#xff0c;\u5426\u5219\u91cd\u542f\u540e\u53c8\u4f1a\u91cd\u590d\u8c03\u7528\u94f6\u884c\u3002<\/p>\n<h3 id=\"%E6%8A%80%E6%9C%AF%E6%A0%88\">\u6280\u672f\u6808<\/h3>\n<ul>\n<li>SpringCloud Alibaba(Nacos)<\/li>\n<li>SpringBoot 2.7.x<\/li>\n<li>RedisTemplate \/ Redisson&#xff08;\u63a8\u8350 Redisson \u5206\u5e03\u5f0f\u9501&#xff0c;\u907f\u514d redis \u8d85\u65f6\u95ee\u9898&#xff09;<\/li>\n<li>Mysql \u5e42\u7b49\u8bb0\u5f55\u8868<\/li>\n<li>Feign \u8c03\u7528\u94f6\u884c\u5916\u90e8\u63a5\u53e3<\/li>\n<li>MQ (RocketMQ) \u4fdd\u9669\u6295\u4fdd\u6d88\u606f\u6d88\u8d39<\/li>\n<\/ul>\n<p>\u751f\u4ea7\u5efa\u8bae&#xff1a;Redis \u505a\u5feb\u901f\u62e6\u622a&#xff0c;Mysql \u5e42\u7b49\u8868\u505a\u6301\u4e45\u515c\u5e95&#xff0c;\u9632\u6b62 Redis \u5b95\u673a\u4e22\u5931\u5e42\u7b49\u6570\u636e\u3002\u53cc\u4fdd\u9669&#xff0c;\u91d1\u878d\u4e1a\u52a1\u4e0d\u80fd\u53ea\u4f9d\u8d56 Redis\u3002<\/p>\n<hr \/>\n<h2 id=\"%E5%AE%9E%E6%88%98%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81\">\u5b9e\u6218\u5b8c\u6574\u4ee3\u7801<\/h2>\n<h3 id=\"1.%20%E5%B9%82%E7%AD%89%E6%95%B0%E6%8D%AE%E5%BA%93%E8%A1%A8%EF%BC%88%E9%87%91%E8%9E%8D%E5%BF%85%E5%AD%98%EF%BC%8C%E5%85%9C%E5%BA%95%EF%BC%89\">1. \u5e42\u7b49\u6570\u636e\u5e93\u8868&#xff08;\u91d1\u878d\u5fc5\u5b58&#xff0c;\u515c\u5e95&#xff09;<\/h3>\n<p>sql<\/p>\n<p>CREATE TABLE &#096;biz_idempotent_record&#096; (<br \/>\n  &#096;id&#096; bigint NOT NULL AUTO_INCREMENT COMMENT &#039;\u4e3b\u952e&#039;,<br \/>\n  &#096;biz_type&#096; varchar(32) NOT NULL COMMENT &#039;\u4e1a\u52a1\u7c7b\u578b&#xff1a;BANK_PAY\u94f6\u884c\u652f\u4ed8\u3001INSURE_APPLY\u6295\u4fdd\u7533\u8bf7\u3001BANK_CALLBACK\u94f6\u884c\u56de\u8c03&#039;,<br \/>\n  &#096;biz_no&#096; varchar(64) NOT NULL COMMENT &#039;\u4e1a\u52a1\u552f\u4e00\u53f7&#xff1a;\u4ea4\u6613\u6d41\u6c34\/\u6295\u4fdd\u5355\u53f7&#xff0c;\u5e42\u7b49key&#039;,<br \/>\n  &#096;status&#096; tinyint NOT NULL COMMENT &#039;0\u5904\u7406\u4e2d 1\u5904\u7406\u6210\u529f 2\u5904\u7406\u5931\u8d25&#039;,<br \/>\n  &#096;response_data&#096; text COMMENT &#039;\u5916\u90e8\u63a5\u53e3\u8fd4\u56de\u7ed3\u679c&#xff0c;\u91cd\u590d\u8bf7\u6c42\u76f4\u63a5\u8fd4\u56de\u8be5\u6570\u636e&#039;,<br \/>\n  &#096;remark&#096; varchar(512) DEFAULT NULL COMMENT &#039;\u5907\u6ce8&#039;,<br \/>\n  &#096;create_time&#096; datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,<br \/>\n  &#096;update_time&#096; datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,<br \/>\n  PRIMARY KEY (&#096;id&#096;),<br \/>\n  UNIQUE KEY &#096;uk_biztype_bizno&#096; (&#096;biz_type&#096;,&#096;biz_no&#096;) COMMENT &#039;\u552f\u4e00\u7d22\u5f15&#xff0c;\u6570\u636e\u5e93\u515c\u5e95\u5e42\u7b49&#xff0c;\u9632\u6b62\u91cd\u590d\u63d2\u5165&#039;<br \/>\n) ENGINE&#061;InnoDB DEFAULT CHARSET&#061;utf8mb4 COMMENT&#061;&#039;\u4e1a\u52a1\u5e42\u7b49\u8bb0\u5f55\u8868&#039;;<\/p>\n<h3 id=\"2.%20%E5%B9%82%E7%AD%89%E7%8A%B6%E6%80%81%E6%9E%9A%E4%B8%BE\">2. \u5e42\u7b49\u72b6\u6001\u679a\u4e3e<\/h3>\n<p>java<\/p>\n<p>public enum IdempotentStatusEnum {<br \/>\n    PROCESSING(0, &#034;\u5904\u7406\u4e2d&#034;),<br \/>\n    SUCCESS(1, &#034;\u5904\u7406\u6210\u529f&#034;),<br \/>\n    FAIL(2, &#034;\u5904\u7406\u5931\u8d25&#034;);<\/p>\n<p>    private final int code;<br \/>\n    private final String desc;<br \/>\n    \/\/\u6784\u9020 getter<br \/>\n}<\/p>\n<h3 id=\"3.%20%E8%87%AA%E5%AE%9A%E4%B9%89%E6%B3%A8%E8%A7%A3%EF%BC%9A%40Idempotent%20%E6%96%B9%E4%BE%BF%20AOP%20%E5%88%87%E9%9D%A2%E5%AE%9E%E7%8E%B0%E5%B9%82%E7%AD%89%EF%BC%88%E9%93%B6%E8%A1%8C%E4%BF%9D%E9%99%A9%E4%B8%9A%E5%8A%A1%EF%BC%89\">3. \u81ea\u5b9a\u4e49\u6ce8\u89e3&#xff1a;&#064;Idempotent \u65b9\u4fbf AOP \u5207\u9762\u5b9e\u73b0\u5e42\u7b49&#xff08;\u94f6\u884c\u4fdd\u9669\u4e1a\u52a1&#xff09;<\/h3>\n<p>\u6ce8\u89e3\u4f5c\u7528&#xff1a;\u52a0\u5728 Feign \u8c03\u7528\u94f6\u884c\u5916\u90e8\u63a5\u53e3\u65b9\u6cd5\u3001Controller \u56de\u8c03\u63a5\u53e3\u3001MQ \u6d88\u8d39\u65b9\u6cd5\u4e0a\u3002<\/p>\n<p>java<\/p>\n<p>&#064;Target({ElementType.METHOD})<br \/>\n&#064;Retention(RetentionPolicy.RUNTIME)<br \/>\npublic &#064;interface Idempotent {<\/p>\n<p>    \/**<br \/>\n     * \u4e1a\u52a1\u7c7b\u578b \u5bf9\u5e94biz_idempotent_record biz_type<br \/>\n     *\/<br \/>\n    String bizType();<\/p>\n<p>    \/**<br \/>\n     * SPEL\u8868\u8fbe\u5f0f&#xff0c;\u83b7\u53d6\u4e1a\u52a1\u552f\u4e00\u7f16\u53f7bizNo<br \/>\n     * \u4f8b\u5982 &#034;#tradeNo&#034;  &#034;#policyApplyDTO.policyNo&#034; &#034;#param.tradeNo&#034;<br \/>\n     *\/<br \/>\n    String bizNoSpel();<\/p>\n<p>    \/**<br \/>\n     * \u5e42\u7b49\u9501\u8fc7\u671f\u65f6\u95f4 \u79d2&#xff0c;\u8c03\u7528\u94f6\u884c\u5916\u90e8\u63a5\u53e3\u6700\u5927\u8d85\u65f6\u65f6\u95f4&#xff0c;\u6bd4\u5982300s&#xff0c;\u9632\u6b62\u6b7b\u9501<br \/>\n     *\/<br \/>\n    long lockExpireSeconds() default 300;<\/p>\n<p>    \/**<br \/>\n     * \u662f\u5426\u9700\u8981\u5b58\u50a8\u8fd4\u56de\u7ed3\u679c&#xff0c;\u91cd\u590d\u8bf7\u6c42\u76f4\u63a5\u8fd4\u56de\u65e7\u7ed3\u679c<br \/>\n     *\/<br \/>\n    boolean saveResponse() default true;<br \/>\n}<\/p>\n<h3 id=\"4.%20AOP%20%E5%88%87%E9%9D%A2%E6%A0%B8%E5%BF%83%E5%AE%9E%E7%8E%B0%EF%BC%88%E5%B9%82%E7%AD%89%E6%A0%B8%E5%BF%83%E9%80%BB%E8%BE%91%EF%BC%89\">4. AOP \u5207\u9762\u6838\u5fc3\u5b9e\u73b0&#xff08;\u5e42\u7b49\u6838\u5fc3\u903b\u8f91&#xff09;<\/h3>\n<p>\u4f7f\u7528 Redisson RLock \u5206\u5e03\u5f0f\u9501&#xff0c;\u89e3\u51b3 Redis \u5355\u70b9\u3001\u9501\u7eed\u671f\u95ee\u9898&#xff0c;\u91d1\u878d\u73af\u5883\u4f18\u5148 Redisson&#xff0c;\u4e0d\u8981\u624b\u5199 setnx\u3002 \u6d41\u7a0b&#xff1a;\u89e3\u6790 spel \u62ff\u5230 bizNo \u2192 \u5c1d\u8bd5\u83b7\u53d6\u5206\u5e03\u5f0f\u9501 \u2192 \u67e5\u8be2\u5e42\u7b49\u8bb0\u5f55\u8868<\/p>\n<li>status &#061; \u6210\u529f&#xff1a;\u76f4\u63a5\u8fd4\u56de\u5386\u53f2 response&#xff0c;\u4e0d\u6267\u884c\u539f\u65b9\u6cd5&#xff08;\u4e0d\u518d\u8c03\u7528\u94f6\u884c\u5916\u90e8\u63a5\u53e3&#xff09;<\/li>\n<li>status &#061; \u5904\u7406\u4e2d&#xff1a;\u629b\u51fa\u91cd\u590d\u8bf7\u6c42\u5f02\u5e38<\/li>\n<li>status &#061; \u5931\u8d25 \/ \u65e0\u8bb0\u5f55&#xff1a;\u6267\u884c\u4e1a\u52a1\u903b\u8f91&#xff08;\u8c03\u7528\u94f6\u884c Feign \u63a5\u53e3&#xff09;<\/li>\n<li>\u6267\u884c\u6210\u529f&#xff1a;\u4fdd\u5b58\u5e42\u7b49\u8bb0\u5f55\u72b6\u6001\u6210\u529f&#xff0c;\u5b58\u50a8\u5916\u90e8\u94f6\u884c\u8fd4\u56de\u62a5\u6587<\/li>\n<li>\u6267\u884c\u5f02\u5e38&#xff1a;\u66f4\u65b0\u72b6\u6001\u4e3a\u5931\u8d25&#xff1b;\u26a0\ufe0f\u5982\u679c\u7b2c\u4e09\u65b9\u94f6\u884c\u5df2\u7ecf\u6267\u884c\u6210\u529f\u672c\u5730\u5b95\u673a&#xff0c;\u8fd9\u91cc\u4e0d\u80fd\u5220\u9664\u5e42\u7b49\u8bb0\u5f55&#xff01;<\/li>\n<p>java<\/p>\n<p>&#064;Aspect<br \/>\n&#064;Component<br \/>\n&#064;Slf4j<br \/>\npublic class IdempotentAspect {<\/p>\n<p>    &#064;Autowired<br \/>\n    private RedissonClient redissonClient;<br \/>\n    &#064;Autowired<br \/>\n    private BizIdempotentRecordMapper idempotentRecordMapper;<br \/>\n    &#064;Autowired<br \/>\n    private SpelExpressionParser spelExpressionParser;<\/p>\n<p>    private static final String LOCK_PREFIX &#061; &#034;idempotent:lock:&#034;;<\/p>\n<p>    &#064;Around(&#034;&#064;annotation(idempotentAnno)&#034;)<br \/>\n    public Object around(ProceedingJoinPoint joinPoint, Idempotent idempotentAnno) throws Throwable {<br \/>\n        String bizType &#061; idempotentAnno.bizType();<br \/>\n        String bizNoSpel &#061; idempotentAnno.bizNoSpel();<br \/>\n        long lockExpire &#061; idempotentAnno.lockExpireSeconds();<br \/>\n        boolean saveResp &#061; idempotentAnno.saveResponse();<\/p>\n<p>        \/\/1 SPEL\u89e3\u6790\u83b7\u53d6\u4e1a\u52a1\u552f\u4e00\u53f7 bizNo<br \/>\n        Object[] args &#061; joinPoint.getArgs();<br \/>\n        EvaluationContext context &#061; new StandardEvaluationContext();<br \/>\n        for (int i &#061; 0; i &lt; args.length; i&#043;&#043;) {<br \/>\n            context.setVariable(&#034;param&#034; &#043; i, args[i]);<br \/>\n        }<br \/>\n        \/\/\u517c\u5bb9\u76f4\u63a5\u5199 #tradeNo<br \/>\n        Expression expression &#061; spelExpressionParser.parseExpression(bizNoSpel);<br \/>\n        String bizNo &#061; expression.getValue(context, String.class);<br \/>\n        if(StringUtils.isBlank(bizNo)){<br \/>\n            throw new RuntimeException(&#034;\u4e1a\u52a1\u552f\u4e00\u7f16\u53f7bizNo\u4e0d\u80fd\u4e3a\u7a7a&#xff0c;\u65e0\u6cd5\u505a\u5e42\u7b49&#034;);<br \/>\n        }<\/p>\n<p>        String lockKey &#061; LOCK_PREFIX &#043; bizType &#043; &#034;:&#034; &#043; bizNo;<br \/>\n        RLock rLock &#061; redissonClient.getLock(lockKey);<\/p>\n<p>        \/\/2 \u83b7\u53d6\u5206\u5e03\u5f0f\u9501<br \/>\n        boolean lockOk &#061; rLock.tryLock(0, lockExpire, TimeUnit.SECONDS);<br \/>\n        if(!lockOk){<br \/>\n            log.warn(&#034;\u5e42\u7b49\u83b7\u53d6\u9501\u5931\u8d25&#xff0c;\u91cd\u590d\u8bf7\u6c42 bizType:{},bizNo:{}&#034;,bizType,bizNo);<br \/>\n            throw new RuntimeException(&#034;\u8bf7\u6c42\u6b63\u5728\u5904\u7406\u4e2d&#xff0c;\u8bf7\u52ff\u91cd\u590d\u63d0\u4ea4&#034;);<br \/>\n        }<br \/>\n        try {<br \/>\n            \/\/3 \u67e5\u8be2\u6570\u636e\u5e93\u5e42\u7b49\u8bb0\u5f55\u515c\u5e95<br \/>\n            BizIdempotentRecord record &#061; idempotentRecordMapper.selectByBiz(bizType, bizNo);<br \/>\n            if(record !&#061; null){<br \/>\n                if(IdempotentStatusEnum.SUCCESS.getCode() &#061;&#061; record.getStatus()){<br \/>\n                    \/\/\u5df2\u7ecf\u5904\u7406\u5b8c\u6210&#xff01;\u76f4\u63a5\u8fd4\u56de\u5386\u53f2\u5b58\u50a8\u7684\u7ed3\u679c&#xff0c;\u4e0d\u518d\u8c03\u7528\u94f6\u884c\u5916\u90e8\u63a5\u53e3&#xff01;&#xff01;\u5e42\u7b49\u6838\u5fc3<br \/>\n                    log.info(&#034;\u5e42\u7b49\u547d\u4e2d&#xff0c;\u76f4\u63a5\u8fd4\u56de\u5386\u53f2\u7ed3\u679c bizType:{},bizNo:{}&#034;,bizType,bizNo);<br \/>\n                    if(saveResp){<br \/>\n                        \/\/json\u53cd\u5e8f\u5217\u5316\u8fd4\u56de\u5bf9\u8c61&#xff1b;\u5982\u679c\u662fcontroller\u53ef\u4ee5\u8fd4\u56dejson<br \/>\n                        return JSON.parse(record.getResponseData());<br \/>\n                    }else {<br \/>\n                        return null;<br \/>\n                    }<br \/>\n                }<br \/>\n                if(IdempotentStatusEnum.PROCESSING.getCode() &#061;&#061; record.getStatus()){<br \/>\n                    throw new RuntimeException(&#034;\u4e1a\u52a1\u5904\u7406\u4e2d&#xff0c;\u7981\u6b62\u91cd\u590d\u8c03\u7528\u94f6\u884c\u63a5\u53e3&#034;);<br \/>\n                }<br \/>\n                \/\/status&#061;FAIL&#xff0c;\u5141\u8bb8\u91cd\u8bd5&#xff0c;\u5f80\u4e0b\u8d70\u6267\u884c\u4e1a\u52a1<br \/>\n            }else{<br \/>\n                \/\/\u65e0\u8bb0\u5f55&#xff0c;\u63d2\u5165\u5e42\u7b49\u8bb0\u5f55 \u72b6\u6001&#061;\u5904\u7406\u4e2d<br \/>\n                BizIdempotentRecord insert &#061; new BizIdempotentRecord();<br \/>\n                insert.setBizType(bizType);<br \/>\n                insert.setBizNo(bizNo);<br \/>\n                insert.setStatus(IdempotentStatusEnum.PROCESSING.getCode());<br \/>\n                insert.setResponseData(null);<br \/>\n                try {<br \/>\n                    idempotentRecordMapper.insert(insert);<br \/>\n                }catch (DuplicateKeyException e){<br \/>\n                    \/\/\u552f\u4e00\u7d22\u5f15\u51b2\u7a81&#xff0c;\u5e76\u53d1\u573a\u666f\u53e6\u4e00\u4e2a\u7ebf\u7a0b\u63d2\u5165\u6210\u529f&#xff0c;\u89c6\u4e3a\u91cd\u590d\u8bf7\u6c42<br \/>\n                    throw new RuntimeException(&#034;\u5e76\u53d1\u91cd\u590d\u8bf7\u6c42&#034;);<br \/>\n                }<br \/>\n            }<\/p>\n<p>            \/\/ &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u6267\u884c\u4e1a\u52a1\u903b\u8f91&#xff1a;\u8c03\u7528\u94f6\u884c\u5916\u90e8Feign\u63a5\u53e3 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\n            Object result &#061; joinPoint.proceed();<\/p>\n<p>            \/\/\u4e1a\u52a1\u6267\u884c\u6210\u529f&#xff0c;\u66f4\u65b0\u5e42\u7b49\u8bb0\u5f55\u4e3a\u6210\u529f&#xff0c;\u4fdd\u5b58\u7b2c\u4e09\u65b9\u8fd4\u56de\u62a5\u6587<br \/>\n            BizIdempotentRecord update &#061; new BizIdempotentRecord();<br \/>\n            update.setBizType(bizType);<br \/>\n            update.setBizNo(bizNo);<br \/>\n            update.setStatus(IdempotentStatusEnum.SUCCESS.getCode());<br \/>\n            if(saveResp){<br \/>\n                update.setResponseData(JSON.toJSONString(result));<br \/>\n            }<br \/>\n            idempotentRecordMapper.updateByBiz(update);<\/p>\n<p>            return result;<br \/>\n        }catch (Throwable e){<br \/>\n            log.error(&#034;\u5e42\u7b49\u6267\u884c\u4e1a\u52a1\u5f02\u5e38 bizType:{},bizNo:{}&#034;,bizType,bizNo,e);<br \/>\n            \/\/\u26a0\ufe0f\u91d1\u878d\u573a\u666f\u5173\u952e\u70b9&#xff1a;\u8fd9\u91cc\u4e0d\u80fd\u5220\u9664\u5e42\u7b49\u8bb0\u5f55&#xff01;<br \/>\n            \/\/\u5982\u679c\u8c03\u7528\u94f6\u884c\u5916\u90e8\u63a5\u53e3\u5df2\u7ecf\u6263\u6b3e\u6210\u529f&#xff0c;\u6211\u65b9\u672c\u5730\u629b\u51fa\u5f02\u5e38&#xff0c;\u5220\u9664\u5e42\u7b49key\u4f1a\u5bfc\u81f4\u91cd\u542f\u540e\u518d\u6b21\u6263\u6b3e&#xff01;<br \/>\n            \/\/\u53ea\u66f4\u65b0\u72b6\u6001\u4e3a\u5931\u8d25&#xff0c;\u4eba\u5de5\/\u5b9a\u65f6\u4efb\u52a1\u6839\u636ebizNo\u5224\u65ad\u662f\u5426\u91cd\u8bd5\u94f6\u884c\u63a5\u53e3<br \/>\n            BizIdempotentRecord failRecord &#061; new BizIdempotentRecord();<br \/>\n            failRecord.setBizType(bizType);<br \/>\n            failRecord.setBizNo(bizNo);<br \/>\n            failRecord.setStatus(IdempotentStatusEnum.FAIL.getCode());<br \/>\n            idempotentRecordMapper.updateByBiz(failRecord);<br \/>\n            throw e;<br \/>\n        }finally {<br \/>\n            if(rLock.isHeldByCurrentThread()){<br \/>\n                rLock.unlock();<br \/>\n            }<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>Mapper \u7b80\u5355\u793a\u4f8b<\/p>\n<p>java<\/p>\n<p>public interface BizIdempotentRecordMapper{<br \/>\n    BizIdempotentRecord selectByBiz(&#064;Param(&#034;bizType&#034;) String bizType,&#064;Param(&#034;bizNo&#034;)String bizNo);<br \/>\n    int insert(BizIdempotentRecord record);<br \/>\n    int updateByBiz(BizIdempotentRecord record);<br \/>\n}<\/p>\n<h3 id=\"5.%20%E5%9C%BA%E6%99%AF%E4%B8%80%EF%BC%9A%E6%88%91%E6%96%B9%E6%9C%8D%E5%8A%A1%20Feign%20%E8%B0%83%E7%94%A8%E9%93%B6%E8%A1%8C%E5%A4%96%E9%83%A8%E6%94%AF%E4%BB%98%E6%8E%A5%E5%8F%A3%EF%BC%88%E9%93%B6%E8%A1%8C%E4%BF%9D%E9%99%A9%E6%94%AF%E4%BB%98%EF%BC%89\">5. \u573a\u666f\u4e00&#xff1a;\u6211\u65b9\u670d\u52a1 Feign \u8c03\u7528\u94f6\u884c\u5916\u90e8\u652f\u4ed8\u63a5\u53e3&#xff08;\u94f6\u884c\u4fdd\u9669\u652f\u4ed8&#xff09;<\/h3>\n<p>java<\/p>\n<p>&#064;Service<br \/>\n&#064;Slf4j<br \/>\npublic class BankInsurancePayService {<\/p>\n<p>    &#064;Autowired<br \/>\n    private BankOuterFeignClient bankOuterFeignClient;<\/p>\n<p>    \/**<br \/>\n     * \u8c03\u7528\u94f6\u884c\u5916\u90e8\u6263\u6b3e\u63a5\u53e3<br \/>\n     * bizNo&#xff1a;\u94f6\u884c\u4ea4\u6613\u6d41\u6c34\u53f7&#xff0c;\u5168\u5c40\u552f\u4e00<br \/>\n     *\/<br \/>\n    &#064;Idempotent(bizType &#061; &#034;BANK_PAY&#034;, bizNoSpel &#061; &#034;#tradeNo&#034;, lockExpireSeconds &#061; 300)<br \/>\n    public BankPayResp bankPay(String tradeNo, Long amount){<br \/>\n        log.info(&#034;\u5f00\u59cb\u8c03\u7528\u94f6\u884c\u5916\u90e8\u6263\u6b3e\u63a5\u53e3 tradeNo&#061;{}&#034;,tradeNo);<br \/>\n        BankPayReq req &#061; new BankPayReq();<br \/>\n        req.setTradeNo(tradeNo);<br \/>\n        req.setAmount(amount);<br \/>\n        \/\/feign\u8c03\u7528\u94f6\u884c\u5916\u90e8http\u63a5\u53e3<br \/>\n        BankPayResp resp &#061; bankOuterFeignClient.pay(req);<br \/>\n        log.info(&#034;\u94f6\u884c\u5916\u90e8\u63a5\u53e3\u8fd4\u56de resp&#061;{}&#034;,resp);<br \/>\n        return resp;<br \/>\n    }<br \/>\n}<\/p>\n<p>\u6548\u679c&#xff1a;<\/p>\n<ul>\n<li>\u7b2c\u4e00\u6b21\u8c03\u7528&#xff1a;\u63d2\u5165\u5e42\u7b49\u8bb0\u5f55 processing \u2192 \u8c03\u7528\u94f6\u884c\u63a5\u53e3\u6210\u529f \u2192 \u66f4\u65b0\u4e3a SUCCESS&#xff0c;\u5b58\u8fd4\u56de\u62a5\u6587<\/li>\n<li>\u7f51\u7edc\u91cd\u8bd5\u518d\u6b21\u8c03\u7528\u540c\u4e00\u4e2a tradeNo&#xff1a;AOP \u76f4\u63a5\u8bfb\u53d6\u6570\u636e\u5e93 responseData \u8fd4\u56de&#xff0c;Feign \u4e0d\u4f1a\u53d1\u8d77\u7b2c\u4e8c\u6b21 http \u8bf7\u6c42\u5230\u94f6\u884c&#xff0c;\u907f\u514d\u91cd\u590d\u6263\u6b3e&#xff01;<\/li>\n<\/ul>\n<h3 id=\"6.%20%E5%9C%BA%E6%99%AF%E4%BA%8C%EF%BC%9A%E9%93%B6%E8%A1%8C%E5%BC%82%E6%AD%A5%E5%9B%9E%E8%B0%83%E6%88%91%E6%96%B9%E4%BF%9D%E9%99%A9%E6%8E%A5%E5%8F%A3%EF%BC%88%E9%93%B6%E8%A1%8C%E5%9B%9E%E8%B0%83%20Controller%EF%BC%89\">6. \u573a\u666f\u4e8c&#xff1a;\u94f6\u884c\u5f02\u6b65\u56de\u8c03\u6211\u65b9\u4fdd\u9669\u63a5\u53e3&#xff08;\u94f6\u884c\u56de\u8c03 Controller&#xff09;<\/h3>\n<p>\u94f6\u884c\u4f1a\u91cd\u590d\u56de\u8c03\u4fdd\u9669\u6295\u4fdd\u7ed3\u679c\u63a5\u53e3&#xff0c;\u5fc5\u987b\u5e42\u7b49&#xff0c;\u9632\u6b62\u91cd\u590d\u751f\u6210\u4fdd\u5355\u3002<\/p>\n<p>java<\/p>\n<p>&#064;RestController<br \/>\n&#064;RequestMapping(&#034;\/bank\/callback&#034;)<br \/>\npublic class BankCallbackController {<\/p>\n<p>    &#064;Autowired<br \/>\n    private InsureService insureService;<\/p>\n<p>    \/**<br \/>\n     * \u94f6\u884c\u6295\u4fdd\u7ed3\u679c\u56de\u8c03&#xff0c;bankTradeNo\u94f6\u884c\u4fa7\u4ea4\u6613\u53f7\u4f5c\u4e3a\u5e42\u7b49key<br \/>\n     *\/<br \/>\n    &#064;PostMapping(&#034;\/insure&#034;)<br \/>\n    &#064;Idempotent(bizType &#061; &#034;BANK_CALLBACK&#034;, bizNoSpel &#061; &#034;#callbackDTO.bankTradeNo&#034;,lockExpireSeconds&#061;600)<br \/>\n    public R&lt;?&gt; insureCallback(&#064;RequestBody BankCallbackDTO callbackDTO){<br \/>\n        \/\/\u6267\u884c\u4e1a\u52a1&#xff1a;\u751f\u6210\u4fdd\u5355\u3001\u66f4\u65b0\u6295\u4fdd\u72b6\u6001<br \/>\n        return insureService.handleBankCallback(callbackDTO);<br \/>\n    }<br \/>\n}<\/p>\n<h3 id=\"7.%20%E5%9C%BA%E6%99%AF%E4%B8%89%EF%BC%9ARocketMQ%20%E6%B6%88%E8%B4%B9%E4%BF%9D%E9%99%A9%E6%8A%95%E4%BF%9D%E6%B6%88%E6%81%AF%EF%BC%88%E9%98%B2%E6%AD%A2%20MQ%20%E9%87%8D%E5%A4%8D%E6%B6%88%E8%B4%B9%EF%BC%89\">7. \u573a\u666f\u4e09&#xff1a;RocketMQ \u6d88\u8d39\u4fdd\u9669\u6295\u4fdd\u6d88\u606f&#xff08;\u9632\u6b62 MQ \u91cd\u590d\u6d88\u8d39&#xff09;<\/h3>\n<p>RocketMQ \u81f3\u5c11\u4e00\u6b21\u6295\u9012&#xff0c;\u5fc5\u7136\u91cd\u590d\u6d88\u606f&#xff0c;\u4e1a\u52a1\u4e0d\u80fd\u91cd\u590d\u6295\u4fdd\u3002<\/p>\n<p>java<\/p>\n<p>&#064;Component<br \/>\n&#064;RocketMQMessageListener(topic &#061; &#034;INSURE_TOPIC&#034;, consumerGroup &#061; &#034;insure-consumer-group&#034;)<br \/>\npublic class InsureMQConsumer implements RocketMQListener&lt;InsureMessage&gt; {<\/p>\n<p>    &#064;Autowired<br \/>\n    private InsureService insureService;<\/p>\n<p>    &#064;Override<br \/>\n    &#064;Idempotent(bizType &#061; &#034;INSURE_APPLY&#034;, bizNoSpel &#061; &#034;#message.policyNo&#034;,lockExpireSeconds&#061;600)<br \/>\n    public void onMessage(InsureMessage message) {<br \/>\n        \/\/\u6295\u4fdd\u4e1a\u52a1\u903b\u8f91&#xff0c;\u751f\u6210\u4fdd\u5355<br \/>\n        insureService.doInsure(message);<br \/>\n    }<br \/>\n}<\/p>\n<h3 id=\"8.%20%E5%85%B3%E9%94%AE%E9%87%91%E8%9E%8D%E5%9D%91%E7%82%B9%EF%BC%88%E9%93%B6%E8%A1%8C%E4%BF%9D%E9%99%A9%E4%B8%9A%E5%8A%A1%E9%87%8D%E7%82%B9%EF%BC%89\">8. \u5173\u952e\u91d1\u878d\u5751\u70b9&#xff08;\u94f6\u884c\u4fdd\u9669\u4e1a\u52a1\u91cd\u70b9&#xff09;<\/h3>\n<h4 id=\"%E5%9D%91%201%EF%BC%9A%E8%B0%83%E7%94%A8%E5%A4%96%E9%83%A8%E9%93%B6%E8%A1%8C%E6%8E%A5%E5%8F%A3%E6%88%90%E5%8A%9F%EF%BC%8C%E6%9C%AC%E5%9C%B0%E6%9C%8D%E5%8A%A1%E5%AE%95%E6%9C%BA\">\u5751 1&#xff1a;\u8c03\u7528\u5916\u90e8\u94f6\u884c\u63a5\u53e3\u6210\u529f&#xff0c;\u672c\u5730\u670d\u52a1\u5b95\u673a<\/h4>\n<p>\u9519\u8bef\u505a\u6cd5&#xff1a;redis \u6210\u529f\u624d\u6267\u884c\u4e1a\u52a1&#xff0c;redis \u5220\u9664 key\u3002\u5b95\u673a key \u4e22\u5931&#xff0c;\u91cd\u8bd5\u518d\u6b21\u8c03\u7528\u94f6\u884c&#xff0c;\u91cd\u590d\u6263\u6b3e\u3002 \u2705\u672c\u65b9\u6848&#xff1a;\u5148\u843d mysql \u5e42\u7b49\u8bb0\u5f55\u72b6\u6001 processing&#xff0c;\u5373\u4f7f Redis \u5168\u6302&#xff0c;Mysql \u552f\u4e00\u7d22\u5f15 &#043; \u8bb0\u5f55\u4f9d\u7136\u62e6\u622a\u91cd\u590d\u8bf7\u6c42\u3002Redis \u9501\u505a\u5e76\u53d1\u63a7\u5236&#xff0c;Mysql \u505a\u6301\u4e45\u5316\u515c\u5e95\u3002<\/p>\n<h4 id=\"%E5%9D%91%202%EF%BC%9A%E9%93%B6%E8%A1%8C%E6%8E%A5%E5%8F%A3%E6%98%AF%E7%BB%93%E6%9E%9C%E6%9C%AA%E7%9F%A5%EF%BC%88%E7%BD%91%E7%BB%9C%E8%B6%85%E6%97%B6%EF%BC%89\">\u5751 2&#xff1a;\u94f6\u884c\u63a5\u53e3\u662f\u7ed3\u679c\u672a\u77e5&#xff08;\u7f51\u7edc\u8d85\u65f6&#xff09;<\/h4>\n<p>\u6211\u65b9\u8c03\u7528\u94f6\u884c\u8d85\u65f6&#xff0c;\u4e0d\u77e5\u9053\u94f6\u884c\u6709\u6ca1\u6709\u6263\u6b3e\u3002<\/p>\n<p>\u4e0d\u80fd\u76f4\u63a5\u6807\u8bb0 SUCCESS&#xff01;\u4e1a\u52a1\u5c42\u9700\u8981\u989d\u5916\u505a\u94f6\u884c\u67e5\u8be2\u63a5\u53e3\u8f6e\u8be2\u5bf9\u8d26&#xff0c;\u6839\u636e\u94f6\u884c\u67e5\u8be2\u7ed3\u679c\u66f4\u65b0\u5e42\u7b49\u8868\u72b6\u6001\u3002 \u5b9a\u65f6\u4efb\u52a1&#xff1a;\u626b\u63cf\u5e42\u7b49\u8868 status&#061;processing \u8d85\u8fc7 5 \u5206\u949f\u7684\u6570\u636e&#xff0c;\u8c03\u7528\u94f6\u884c\u67e5\u8be2\u63a5\u53e3\u6838\u5bf9\u771f\u5b9e\u72b6\u6001\u3002<\/p>\n<h4 id=\"%E5%9D%91%203%EF%BC%9A%E5%B9%82%E7%AD%89%20key%20%E4%B8%8D%E8%A6%81%E7%94%A8%20requestId%EF%BC%8C%E7%BD%91%E5%85%B3%E9%87%8D%E8%AF%95%20requestId%20%E4%BC%9A%E5%8F%98\">\u5751 3&#xff1a;\u5e42\u7b49 key \u4e0d\u8981\u7528 requestId&#xff0c;\u7f51\u5173\u91cd\u8bd5 requestId \u4f1a\u53d8<\/h4>\n<p>\u5e42\u7b49 key \u5fc5\u987b\u662f\u4e1a\u52a1\u4fa7\u771f\u5b9e\u552f\u4e00\u7f16\u53f7&#xff1a;tradeNo policyNo bankTradeNo\u3002<\/p>\n<h4 id=\"%E5%9D%91%204%EF%BC%9A%E9%94%81%E6%97%B6%E9%97%B4%E4%B8%8D%E8%83%BD%E5%A4%AA%E7%9F%AD%EF%BC%8C%E9%93%B6%E8%A1%8C%E5%A4%96%E9%83%A8%E6%8E%A5%E5%8F%A3%E6%9C%89%E6%97%B6%E5%80%99%E6%85%A2%EF%BC%8C%E5%87%A0%E5%8D%81%E7%A7%92%E6%89%8D%E8%BF%94%E5%9B%9E\">\u5751 4&#xff1a;\u9501\u65f6\u95f4\u4e0d\u80fd\u592a\u77ed&#xff0c;\u94f6\u884c\u5916\u90e8\u63a5\u53e3\u6709\u65f6\u5019\u6162&#xff0c;\u51e0\u5341\u79d2\u624d\u8fd4\u56de<\/h4>\n<p>lockExpireSeconds \u8bbe\u7f6e\u5927\u4e8e\u7b2c\u4e09\u65b9\u63a5\u53e3\u6700\u5927\u8d85\u65f6\u65f6\u95f4&#xff0c;Redisson \u81ea\u52a8\u770b\u95e8\u72d7\u7eed\u671f\u3002<\/p>\n<h4 id=\"%E5%9D%91%205%EF%BC%9A%E5%A4%B1%E8%B4%A5%E7%8A%B6%E6%80%81%E8%A6%81%E5%85%81%E8%AE%B8%E9%87%8D%E8%AF%95\">\u5751 5&#xff1a;\u5931\u8d25\u72b6\u6001\u8981\u5141\u8bb8\u91cd\u8bd5<\/h4>\n<p>status&#061;FAIL&#xff0c;\u5e42\u7b49\u5207\u9762\u5141\u8bb8\u4e1a\u52a1\u91cd\u65b0\u6267\u884c&#xff1b;status&#061;SUCCESS \u6c38\u8fdc\u62e6\u622a\u3002<\/p>\n<h3 id=\"9.%20%E9%85%8D%E5%A5%97%EF%BC%9A%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E8%A1%A5%E5%81%BF%EF%BC%88%E9%87%91%E8%9E%8D%E7%94%9F%E4%BA%A7%E5%BF%85%E5%A4%87%EF%BC%89\">9. \u914d\u5957&#xff1a;\u5b9a\u65f6\u4efb\u52a1\u8865\u507f&#xff08;\u91d1\u878d\u751f\u4ea7\u5fc5\u5907&#xff09;<\/h3>\n<p>\u626b\u63cfbiz_idempotent_record\u8868&#xff0c;\u5904\u7406\u957f\u65f6\u95f4\u5904\u4e8ePROCESSING\u7684\u6570\u636e&#xff0c;\u4e3b\u52a8\u8c03\u7528\u94f6\u884c\u67e5\u8be2\u63a5\u53e3\u6838\u5bf9\u771f\u5b9e\u4ea4\u6613\u72b6\u6001&#xff0c;\u4fee\u6b63\u5e42\u7b49\u8bb0\u5f55\u3002<\/p>\n<p>java<\/p>\n<p>&#064;Component<br \/>\n&#064;EnableScheduling<br \/>\npublic class IdempotentCompensateTask {<\/p>\n<p>    &#064;Scheduled(fixedRate &#061; 60000)<br \/>\n    public void compensate(){<br \/>\n        \/\/\u67e5\u8be2\u5904\u7406\u4e2d\u8d85\u8fc75\u5206\u949f\u8bb0\u5f55<br \/>\n        List&lt;BizIdempotentRecord&gt; list &#061; idempotentRecordMapper.selectProcessingTimeout();<br \/>\n        for(BizIdempotentRecord record : list){<br \/>\n            \/\/\u8c03\u7528\u94f6\u884c\u67e5\u8be2\u63a5\u53e3&#xff0c;\u67e5\u8be2\u8be5tradeNo\u771f\u5b9e\u72b6\u6001<br \/>\n            BankQueryResp resp &#061; bankOuterFeignClient.queryTrade(record.getBizNo());<br \/>\n            if(resp.isTradeSuccess()){<br \/>\n                \/\/\u94f6\u884c\u4fa7\u5df2\u7ecf\u6210\u529f&#xff0c;\u66f4\u65b0\u5e42\u7b49\u8bb0\u5f55\u4e3a\u6210\u529f&#xff0c;\u6267\u884c\u8865\u4e1a\u52a1\u903b\u8f91<br \/>\n            }else if(resp.isTradeFail()){<br \/>\n                record.setStatus(IdempotentStatusEnum.FAIL.getCode());<br \/>\n                idempotentRecordMapper.updateByBiz(record);<br \/>\n            }else{<br \/>\n                \/\/\u94f6\u884c\u5904\u7406\u4e2d&#xff0c;\u8df3\u8fc7&#xff0c;\u4e0b\u6b21\u5b9a\u65f6\u518d\u626b<br \/>\n            }<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h3 id=\"10.%20%E5%85%B6%E4%BB%96%E8%A1%A5%E5%85%85\">10. \u5176\u4ed6\u8865\u5145<\/h3>\n<li>\u524d\u7aef\u63d0\u4ea4\u6295\u4fdd&#xff1a;\u642d\u914d Token \u5e42\u7b49&#xff0c;\u9632\u6b62\u524d\u7aef\u72c2\u70b9&#xff0c;Token \u53ea\u62e6\u622a\u5165\u53e3&#xff1b;\u771f\u6b63\u9632\u91cd\u590d\u8fd8\u662f\u540e\u7aef\u4e1a\u52a1\u5e42\u7b49\u8868&#xff0c;\u56e0\u4e3a\u5916\u90e8\u56de\u8c03\u3001MQ \u4e0d\u8d70\u524d\u7aef\u3002<\/li>\n<li>\u4fdd\u5355\u5185\u90e8\u66f4\u65b0\u64cd\u4f5c&#xff1a;\u642d\u914d\u4e50\u89c2\u9501 update policy set status&#061;2 where id&#061;xxx and status&#061;1&#xff0c;\u9632\u6b62\u72b6\u6001\u9519\u4e71\u3002<\/li>\n<li>Feign \u8c03\u7528\u94f6\u884c\u63a5\u53e3&#xff0c;\u505a\u597d\u8d85\u65f6\u3001\u91cd\u8bd5\u914d\u7f6e&#xff1b;\u91cd\u8bd5\u4e00\u5b9a\u914d\u5408\u5e42\u7b49&#xff0c;\u5426\u5219\u91cd\u8bd5 &#061; \u91cd\u590d\u6263\u6b3e\u3002<\/li>\n<p>yaml<\/p>\n<p>feign:<br \/>\n  client:<br \/>\n    config:<br \/>\n      default:<br \/>\n        connectTimeout: 10000<br \/>\n        readTimeout: 30000<br \/>\n        retryer: feign.Retryer.Default #\u5f00\u542f\u91cd\u8bd5&#xff0c;\u524d\u63d0\u4e1a\u52a1\u65b9\u6cd5\u5fc5\u987b\u52a0&#064;Idempotent<\/p>\n<h3 id=\"%E6%95%B4%E4%BD%93%E6%B5%81%E7%A8%8B%E6%80%BB%E7%BB%93\">\u6574\u4f53\u6d41\u7a0b\u603b\u7ed3<\/h3>\n<li>\u91cd\u590d\u8bf7\u6c42\u8fdb\u6765&#xff0c;AOP \u5207\u9762\u83b7\u53d6\u4e1a\u52a1\u552f\u4e00\u7f16\u53f7<\/li>\n<li>Redisson \u5206\u5e03\u5f0f\u9501\u62e6\u622a\u5e76\u53d1<\/li>\n<li>\u67e5\u8be2 Mysql \u5e42\u7b49\u8bb0\u5f55\u8868\n<ul>\n<li>SUCCESS&#xff1a;\u76f4\u63a5\u8fd4\u56de\u5386\u53f2\u7ed3\u679c&#xff0c;\u4e0d\u8bbf\u95ee\u94f6\u884c\u5916\u90e8\u63a5\u53e3<\/li>\n<li>PROCESSING&#xff1a;\u62d2\u7edd\u8bf7\u6c42<\/li>\n<li>FAIL&#xff1a;\u5141\u8bb8\u91cd\u8bd5\u6267\u884c\u4e1a\u52a1<\/li>\n<\/ul>\n<\/li>\n<li>\u6267\u884c\u4e1a\u52a1\u8c03\u7528\u94f6\u884c Feign \u63a5\u53e3<\/li>\n<li>\u6210\u529f\u66f4\u65b0\u5e42\u7b49\u8bb0\u5f55&#xff0c;\u4fdd\u5b58\u94f6\u884c\u8fd4\u56de\u62a5\u6587&#xff1b;\u5931\u8d25\u66f4\u65b0\u72b6\u6001\u4e3a FAIL<\/li>\n<li>\u5b9a\u65f6\u8865\u507f\u4efb\u52a1\u626b\u63cf\u5904\u7406\u4e2d\u8bb0\u5f55&#xff0c;\u8c03\u7528\u94f6\u884c\u67e5\u8be2\u63a5\u53e3\u5bf9\u8d26\u515c\u5e95\u3002<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55<br \/>\n\u65b9\u6848\u9009\u578b&#xff08;\u94f6\u884c\u4fdd\u9669\u751f\u4ea7\u5e38\u7528&#xff09;<br \/>\n\u6280\u672f\u6808<br \/>\n\u5b9e\u6218\u5b8c\u6574\u4ee3\u7801<br \/>\n1. \u5e42\u7b49\u6570\u636e\u5e93\u8868&#xff08;\u91d1\u878d\u5fc5\u5b58&#xff0c;\u515c\u5e95&#xff09;<br \/>\n2. \u5e42\u7b49\u72b6\u6001\u679a\u4e3e<br \/>\n3. \u81ea\u5b9a\u4e49\u6ce8\u89e3&#xff1a;Idempotent \u65b9\u4fbf AOP \u5207\u9762\u5b9e\u73b0\u5e42\u7b49&#xff08;\u94f6\u884c\u4fdd\u9669\u4e1a\u52a1&#xff09;<br \/>\n4. AOP \u5207\u9762\u6838\u5fc3\u5b9e\u73b0&#xff08;\u5e42\u7b49\u6838\u5fc3\u903b\u8f91&#xff09;<br \/>\n5. \u573a\u666f\u4e00&#xff1a;\u6211\u65b9\u670d\u52a1 Feign \u8c03\u7528\u94f6\u884c\u5916\u90e8\u652f\u4ed8\u63a5\u53e3&amp;#xff<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[101,963,292],"topic":[],"class_list":["post-102509","post","type-post","status-publish","format-standard","hentry","category-server","tag-spring","tag-spring-cloud","tag-292"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SpringCloud \u94f6\u884c\u4fdd\u9669\u4e1a\u52a1 \u5916\u90e8\u8c03\u7528\u63a5\u53e3\u5e42\u7b49\u5b9e\u6218 - \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\/102509.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SpringCloud \u94f6\u884c\u4fdd\u9669\u4e1a\u52a1 \u5916\u90e8\u8c03\u7528\u63a5\u53e3\u5e42\u7b49\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 \u65b9\u6848\u9009\u578b&#xff08;\u94f6\u884c\u4fdd\u9669\u751f\u4ea7\u5e38\u7528&#xff09; \u6280\u672f\u6808 \u5b9e\u6218\u5b8c\u6574\u4ee3\u7801 1. \u5e42\u7b49\u6570\u636e\u5e93\u8868&#xff08;\u91d1\u878d\u5fc5\u5b58&#xff0c;\u515c\u5e95&#xff09; 2. \u5e42\u7b49\u72b6\u6001\u679a\u4e3e 3. \u81ea\u5b9a\u4e49\u6ce8\u89e3&#xff1a;Idempotent \u65b9\u4fbf AOP \u5207\u9762\u5b9e\u73b0\u5e42\u7b49&#xff08;\u94f6\u884c\u4fdd\u9669\u4e1a\u52a1&#xff09; 4. AOP \u5207\u9762\u6838\u5fc3\u5b9e\u73b0&#xff08;\u5e42\u7b49\u6838\u5fc3\u903b\u8f91&#xff09; 5. \u573a\u666f\u4e00&#xff1a;\u6211\u65b9\u670d\u52a1 Feign \u8c03\u7528\u94f6\u884c\u5916\u90e8\u652f\u4ed8\u63a5\u53e3&amp;#xff\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/102509.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-08T15:17:04+00:00\" \/>\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\/102509.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/102509.html\",\"name\":\"SpringCloud \u94f6\u884c\u4fdd\u9669\u4e1a\u52a1 \u5916\u90e8\u8c03\u7528\u63a5\u53e3\u5e42\u7b49\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-08T15:17:04+00:00\",\"dateModified\":\"2026-09-08T15:17:04+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/102509.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/102509.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102509.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SpringCloud \u94f6\u884c\u4fdd\u9669\u4e1a\u52a1 \u5916\u90e8\u8c03\u7528\u63a5\u53e3\u5e42\u7b49\u5b9e\u6218\"}]},{\"@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":"SpringCloud \u94f6\u884c\u4fdd\u9669\u4e1a\u52a1 \u5916\u90e8\u8c03\u7528\u63a5\u53e3\u5e42\u7b49\u5b9e\u6218 - \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\/102509.html","og_locale":"zh_CN","og_type":"article","og_title":"SpringCloud \u94f6\u884c\u4fdd\u9669\u4e1a\u52a1 \u5916\u90e8\u8c03\u7528\u63a5\u53e3\u5e42\u7b49\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 \u65b9\u6848\u9009\u578b&#xff08;\u94f6\u884c\u4fdd\u9669\u751f\u4ea7\u5e38\u7528&#xff09; \u6280\u672f\u6808 \u5b9e\u6218\u5b8c\u6574\u4ee3\u7801 1. \u5e42\u7b49\u6570\u636e\u5e93\u8868&#xff08;\u91d1\u878d\u5fc5\u5b58&#xff0c;\u515c\u5e95&#xff09; 2. \u5e42\u7b49\u72b6\u6001\u679a\u4e3e 3. \u81ea\u5b9a\u4e49\u6ce8\u89e3&#xff1a;Idempotent \u65b9\u4fbf AOP \u5207\u9762\u5b9e\u73b0\u5e42\u7b49&#xff08;\u94f6\u884c\u4fdd\u9669\u4e1a\u52a1&#xff09; 4. AOP \u5207\u9762\u6838\u5fc3\u5b9e\u73b0&#xff08;\u5e42\u7b49\u6838\u5fc3\u903b\u8f91&#xff09; 5. \u573a\u666f\u4e00&#xff1a;\u6211\u65b9\u670d\u52a1 Feign \u8c03\u7528\u94f6\u884c\u5916\u90e8\u652f\u4ed8\u63a5\u53e3&amp;#xff","og_url":"https:\/\/www.wsisp.com\/helps\/102509.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-08T15:17:04+00:00","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\/102509.html","url":"https:\/\/www.wsisp.com\/helps\/102509.html","name":"SpringCloud \u94f6\u884c\u4fdd\u9669\u4e1a\u52a1 \u5916\u90e8\u8c03\u7528\u63a5\u53e3\u5e42\u7b49\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-08T15:17:04+00:00","dateModified":"2026-09-08T15:17:04+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/102509.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/102509.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/102509.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"SpringCloud \u94f6\u884c\u4fdd\u9669\u4e1a\u52a1 \u5916\u90e8\u8c03\u7528\u63a5\u53e3\u5e42\u7b49\u5b9e\u6218"}]},{"@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\/102509","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=102509"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102509\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=102509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=102509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=102509"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=102509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}