<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                **1. 資源代碼** ```java @RestController public class RateLimitController { @GetMapping("/protectd/strategy/{code}") @SentinelResource(value = "protectd-strategy" , blockHandlerClass = Customerhandler.class , blockHandler = "handleLimit" //當發生限流時調用該處理方法 , fallbackClass = Customerhandler.class , fallback = "handleFallback") //當發生異常時調用該處理方法 public String protectdStrategy(@PathVariable("code") int code) throws Exception { if (code == 1) { throw new Exception("code等于1,發生異常了!"); } return "正常情況!"; } } ``` **2. 自定義的處理類** ```java public class Customerhandler { public static String handleLimit(int code, BlockException exception) { return "handleLimit---code:" + code + "---message: " + exception.getClass().getCanonicalName(); } public static String handleFallback(int code, Throwable e) { return "handleFallback---code:" + code + "---message: " + e.getMessage(); } } ``` **3. 測試結果** 以較慢的速度訪問 http://localhost:8401//protectd/strategy/1 ,只發生異常,`handleFallback`被調用來處理異常。 ![](https://img.kancloud.cn/b6/a8/b6a8e0cd5fcc5cf45773fff611975e55_1347x198.png) 我設置限流規則為1s只能處理一次請求,當快速訪問 http://localhost:8401//protectd/strategy/1 ,雖然也有異常發生,但是只有處理限流的方法`handleLimit`被調用。 ![](https://img.kancloud.cn/4e/c0/4ec0f054523a04de4f36b292d9d5128b_1241x190.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看