{"id":1284,"date":"2021-03-03T20:24:55","date_gmt":"2021-03-03T12:24:55","guid":{"rendered":"http:\/\/diuut.com\/?p=1284"},"modified":"2021-05-16T15:27:46","modified_gmt":"2021-05-16T07:27:46","slug":"alibaba-sentinel%e5%ae%9e%e7%8e%b0%e6%9c%8d%e5%8a%a1%e9%99%8d%e7%ba%a7","status":"publish","type":"post","link":"https:\/\/diuut.com\/?p=1284","title":{"rendered":"Alibaba Sentinel\u5b9e\u73b0\u670d\u52a1\u964d\u7ea7"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\"><p>\u9700\u6c42<\/p><cite>\u67d0\u4e2a\u5fae\u670d\u52a1\u6302\u4e86\u4e0d\u53ef\u80fd\u5168\u90e8\u4e00\u8d77\u5361\u5728\u90a3\uff0c\u603b\u5f97\u6709\u4e2a\u8865\u507f\u5907\u7528\u65b9\u6848\uff0c\u4ee5\u63d0\u5347\u6574\u4e2a\u670d\u52a1\u7684\u53ef\u7528\u6027\u3002<\/cite><\/blockquote>\n\n\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_66_1 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\">\u76ee\u5f55<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/diuut.com\/?p=1284\/#%E5%BC%95%E5%85%A5%E4%BE%9D%E8%B5%96\" title=\"\u5f15\u5165\u4f9d\u8d56\">\u5f15\u5165\u4f9d\u8d56<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/diuut.com\/?p=1284\/#%E5%90%AF%E5%8A%A8%E9%85%8D%E7%BD%AE\" title=\"\u542f\u52a8\u914d\u7f6e\">\u542f\u52a8\u914d\u7f6e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/diuut.com\/?p=1284\/#Feign%E6%8E%A5%E5%8F%A3%E6%B3%A8%E8%A7%A3%E9%85%8D%E7%BD%AEfallback%E5%8F%82%E6%95%B0\" title=\"Feign\u63a5\u53e3\u6ce8\u89e3\u914d\u7f6efallback\u53c2\u6570\">Feign\u63a5\u53e3\u6ce8\u89e3\u914d\u7f6efallback\u53c2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/diuut.com\/?p=1284\/#%E5%AE%9E%E7%8E%B0%E9%99%8D%E7%BA%A7%E5%A4%84%E7%90%86%E7%B1%BB%EF%BC%88%E8%A1%A5%E5%81%BF%E6%93%8D%E4%BD%9C%E6%88%96%E6%8F%90%E7%A4%BA%EF%BC%89\" title=\"\u5b9e\u73b0\u964d\u7ea7\u5904\u7406\u7c7b\uff08\u8865\u507f\u64cd\u4f5c\u6216\u63d0\u793a\uff09\">\u5b9e\u73b0\u964d\u7ea7\u5904\u7406\u7c7b\uff08\u8865\u507f\u64cd\u4f5c\u6216\u63d0\u793a\uff09<\/a><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"%E5%BC%95%E5%85%A5%E4%BE%9D%E8%B5%96\"><\/span>\u5f15\u5165\u4f9d\u8d56<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n        &lt;dependency&gt;\n            &lt;groupId&gt;com.alibaba.cloud&lt;\/groupId&gt;\n            &lt;artifactId&gt;spring-cloud-starter-alibaba-sentinel&lt;\/artifactId&gt;\n        &lt;\/dependency&gt;\n<\/pre><\/div>\n\n\n<h4><span class=\"ez-toc-section\" id=\"%E5%90%AF%E5%8A%A8%E9%85%8D%E7%BD%AE\"><\/span>\u542f\u52a8\u914d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: yaml; title: ; notranslate\" title=\"\">\nfeign:\n  sentinel:\n    enabled: true\n<\/pre><\/div>\n\n\n<h4><span class=\"ez-toc-section\" id=\"Feign%E6%8E%A5%E5%8F%A3%E6%B3%A8%E8%A7%A3%E9%85%8D%E7%BD%AEfallback%E5%8F%82%E6%95%B0\"><\/span>Feign\u63a5\u53e3\u6ce8\u89e3\u914d\u7f6efallback\u53c2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n@FeignClient(name = &quot;common-message&quot;,fallback = MessageFeignClientFallback.class)\npublic interface MessageFeignClient {\n    @ResponseBody\n    @RequestMapping(value = &quot;\/sms\/{phone}\/{code}&quot;,method = RequestMethod.GET)\n    public String sendSms(@PathVariable(name = &quot;phone&quot;) String phone, @PathVariable(name = &quot;code&quot;) String code);\n}\n<\/pre><\/div>\n\n\n<h4><span class=\"ez-toc-section\" id=\"%E5%AE%9E%E7%8E%B0%E9%99%8D%E7%BA%A7%E5%A4%84%E7%90%86%E7%B1%BB%EF%BC%88%E8%A1%A5%E5%81%BF%E6%93%8D%E4%BD%9C%E6%88%96%E6%8F%90%E7%A4%BA%EF%BC%89\"><\/span>\u5b9e\u73b0\u964d\u7ea7\u5904\u7406\u7c7b\uff08\u8865\u507f\u64cd\u4f5c\u6216\u63d0\u793a\uff09<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n@Component\npublic class MessageFeignClientFallback implements MessageFeignClient {\n    @Override\n    public String sendSms(String phone, String code) {\n        return &quot;Message \u670d\u52a1\u5df2\u5173\u95ed\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u542f\u52a8&quot;;\n    }\n}\n<\/pre><\/div>\n\n\n<p>\u4ee5\u4e0a\u5b8c\u6210\u540e\uff0c\u76f8\u5f53\u4e8e\u5982\u679c\u8c03\u7528\u7684\u5fae\u670d\u52a1\u63a5\u53e3\u51fa\u73b0\u5f02\u5e38\uff0c\u5c31\u6293\u53d6\u5f02\u5e38\u5e76\u8fdb\u884c\u7c7b\u4f3ccatch\u7684\u5904\u7406\uff0c\u800c\u4e14\u4ee5\u4e0a\u6b65\u9aa4\u662f\u65e0\u4fb5\u5165\u5f0f\u7684\u3002\u5982\u679c\u9700\u8981\u8fdb\u884c\u9650\u6d41\u6216\u8005\u7194\u65ad\u7684\u64cd\u4f5c\u7684\u8bdd\u5219\u9700\u8981\u542f\u52a8sentinel\u63a7\u5236\u53f0\u8fdb\u884c\u914d\u7f6e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9700\u6c42 \u67d0\u4e2a\u5fae\u670d\u52a1\u6302\u4e86\u4e0d\u53ef\u80fd\u5168\u90e8\u4e00\u8d77\u5361\u5728\u90a3\uff0c\u603b\u5f97\u6709\u4e2a\u8865\u507f\u5907\u7528\u65b9\u6848\uff0c\u4ee5\u63d0\u5347\u6574\u4e2a\u670d\u52a1\u7684\u53ef\u7528\u6027\u3002 \u5f15\u5165\u4f9d\u8d56 \u542f\u52a8\u914d\u7f6e <span class=\"more-button\"><a href=\"https:\/\/diuut.com\/?p=1284\" class=\"more-link\">view all . . .<span class=\"screen-reader-text\">Alibaba Sentinel\u5b9e\u73b0\u670d\u52a1\u964d\u7ea7<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":1285,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts\/1284"}],"collection":[{"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1284"}],"version-history":[{"count":7,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts\/1284\/revisions"}],"predecessor-version":[{"id":1346,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts\/1284\/revisions\/1346"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/media\/1285"}],"wp:attachment":[{"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}