利用Springcloud怎么熔斷hystrix服務(wù)-創(chuàng)新互聯(lián)

這篇文章給大家介紹利用Springcloud怎么熔斷hystrix服務(wù),內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到德州網(wǎng)站設(shè)計(jì)與德州網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊(cè)、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋德州地區(qū)。

1.主啟動(dòng)類加上新的注解。


@EnableCircuitBreaker

2.service寫(xiě)入新的熔斷控制方法

@Service
public class PaymentHystrixService {
 @HystrixCommand(fallbackMethod = "paymentCircuitBreaker_fallback",commandProperties = {
      @HystrixProperty(name = "circuitBreaker.enabled", value = "true"),       //是否開(kāi)啟斷路器
      @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "10"),  //請(qǐng)求數(shù)達(dá)到后才計(jì)算
      @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "10000"), //休眠時(shí)間窗
      @HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "60"), //錯(cuò)誤率達(dá)到多少跳閘
  })
  public String paymentCirtuitBreaker(@PathVariable("id")Integer id){
   if(id<0){
     throw new RuntimeException("****id不能為負(fù)數(shù)");
   }
   String randomNum= IdUtil.simpleUUID();

   return Thread.currentThread().getName()+"\t"+"調(diào)用成功,編號(hào)"+randomNum;

  }
  public String paymentCircuitBreaker_fallback(@PathVariable("id")Integer id){
    return "id不能為負(fù)數(shù),請(qǐng)稍后重試,o(╥﹏╥)o+"+id;
  }

網(wǎng)站欄目:利用Springcloud怎么熔斷hystrix服務(wù)-創(chuàng)新互聯(lián)
文章出自:http://muchs.cn/article8/dphgop.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、搜索引擎優(yōu)化自適應(yīng)網(wǎng)站、網(wǎng)站設(shè)計(jì)公司、營(yíng)銷型網(wǎng)站建設(shè)、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)