hystrix熔断指定方法设置超时时间

2022-08-10 08:29:31

一、结论

hystrix:
  command:default:  #default全局有效
      execution:
        timeout:
          #是否开启超时熔断
          enabled:true
        isolation:
          thread:
            timeoutInMilliseconds:6000 #断路器超时时间,默认1000ms
    HystrixCommonKey:  #HystrixCommandKey:要单独设置超时时间的方法
      execution:
        timeout:
          #是否开启超时熔断,默认true
          enabled:true
        isolation:
          thread:
            timeoutInMilliseconds:10000 #断路器超时时间

二、查看HystrixCommandKey

HystrixCommonKey:类名#方法名(参数类型)
publicstatic StringconfigKey(ClasstargetType, Method method){
    StringBuilder builder=newStringBuilder();
    builder.append(targetType.getSimpleName());
    builder.append('#').append(method.getName()).append('(');for(Type param: method.getGenericParameterTypes()){
      param= Types.resolve(targetType, targetType, param);
      builder.append(Types.getRawType(param).getSimpleName()).append(',');}if(method.getParameterTypes().length>0){
      builder.deleteCharAt(builder.length()-1);}return builder.append(')').toString();//打断点,查看自己方法的 HystrixCommonKey}
  • 作者:zmyHow
  • 原文链接:https://blog.csdn.net/weixin_43846916/article/details/106860555
    更新时间:2022-08-10 08:29:31