<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      feign之間傳遞oauth2-token的問題和解決~續

      之前寫過關于修改hystric的隔離《feign之間傳遞oauth2-token的問題和解決》方式來在feign調用各個微服務中傳遞token,修改為SEMAPHORE之后,會有一些性能的問題,可能出現請求積壓,請求雪崩等問題,所以今天需要使用另一種方法,就是通過自定義的隔離對象重寫wrapCallable方法來實現。

      • CustomFeignHystrixConcurrencyStrategy代碼
          import com.netflix.hystrix.strategy.HystrixPlugins;
          import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;
          import lombok.extern.slf4j.Slf4j;
          import org.springframework.context.annotation.Primary;
          import org.springframework.stereotype.Component;
          import org.springframework.web.context.request.RequestAttributes;
          import org.springframework.web.context.request.RequestContextHolder;
           
          import java.util.concurrent.Callable;
           
      
          @Slf4j
          @Primary
          @Component
          public class CustomFeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy {
           
              public CustomFeignHystrixConcurrencyStrategy() {
                  try {
           
                      HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
           
                  } catch (Exception e) {
                      log.error("Failed to register Sleuth Hystrix Concurrency Strategy", e);
                  }
              }
           
              @Override
              public <T> Callable<T> wrapCallable(Callable<T> callable) {
                  RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
                  return new WrappedCallable<>(callable, requestAttributes);
              }
           
              static class WrappedCallable<T> implements Callable<T> {
                  private final Callable<T> target;
                  private final RequestAttributes requestAttributes;
           
                  public WrappedCallable(Callable<T> target, RequestAttributes requestAttributes) {
                      this.target = target;
                      this.requestAttributes = requestAttributes;
                  }
           
                  /**
                   * feign opens the fuse (hystrix): feign.hystrix.enabled=ture, and uses the default signal isolation level,
                   * The HttpServletRequest object is independent of each other in the parent thread and the child thread and is not shared.
                   * So the HttpServletRequest data of the parent thread used in the child thread is null,
                   * naturally it is impossible to obtain the token information of the request header In a multithreaded environment, call before the request, set the context before the call
                   *
                   * feign啟用了hystrix,并且feign.hystrix.enabled=ture。采用了線程隔離策略。
                   * HttpServletRequest 請求在對象在父線程和子線程中相互獨立,且不共享
                   * 所以父線程的 HttpServletRequest 在子線程中為空,
                   * 所以通常 在多線程環境中,在請求調用之前設置上下文
                   * @return T
                   * @throws Exception Exception
                   */
                  @Override
                  public T call() throws Exception {
                      try {
                          // Set true to share the parent thread's HttpServletRequest object setting
                          RequestContextHolder.setRequestAttributes(requestAttributes, true);
                          return target.call();
                      } finally {
                          RequestContextHolder.resetRequestAttributes();
                      }
                  }
              }
          }
      
      
      
      posted @ 2022-08-24 14:00  張占嶺  閱讀(341)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产女高清在线看免费观看 | 国产91精品调教在线播放| 香蕉EEWW99国产精选免费| 精品黄色av一区二区三区 | 日日碰狠狠添天天爽五月婷| 妺妺窝人体色WWW看人体| 国产高清自产拍av在线| 免费A级毛片无码A∨蜜芽试看 | 国产成人午夜福利精品| 日韩精品成人一区二区三| 日韩精品中文字幕有码| 免费人成在线观看网站| 丰满人妻被黑人猛烈进入| 色综合色综合综合综合综合| 欧美精品一区二区三区在线观看| 欧美日韩精品一区二区三区高清视频 | 国产黄色一区二区三区四区| 久久精品免视看国产成人| 日韩一欧美内射在线观看| 亚洲天堂网中文在线资源| 中文字幕国产精品一二区| 国内自拍av在线免费| 免费黄色大全一区二区三区| 东京热加勒比无码少妇| 制服jk白丝h无内视频网站| 国产成人av电影在线观看第一页| 精品人妻伦一二三区久久aaa片| 乱妇乱女熟妇熟女网站| 固安县| 潘金莲高清dvd碟片| 在线观看成人年视频免费| 丁青县| 狠狠久久五月综合色和啪| 国产亚洲精品午夜福利| 久久精品亚洲中文字幕无码网站| 91精品乱码一区二区三区| 国产成人精品中文字幕| 热re99久久精品国产99热| 久青草视频在线观看免费| 国产高清在线男人的天堂 | 三上悠亚精品一区二区久久|