| 
						
						
						
					 | 
					@ -1,5 +1,6 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					package com.epmet.commons.tools.feign; | 
					 | 
					 | 
					package com.epmet.commons.tools.feign; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.commons.tools.constant.ThreadLocalConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.netflix.hystrix.HystrixThreadPoolKey; | 
					 | 
					 | 
					import com.netflix.hystrix.HystrixThreadPoolKey; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.netflix.hystrix.HystrixThreadPoolProperties; | 
					 | 
					 | 
					import com.netflix.hystrix.HystrixThreadPoolProperties; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.netflix.hystrix.strategy.HystrixPlugins; | 
					 | 
					 | 
					import com.netflix.hystrix.strategy.HystrixPlugins; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -17,6 +18,7 @@ import org.springframework.stereotype.Component; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.springframework.web.context.request.RequestAttributes; | 
					 | 
					 | 
					import org.springframework.web.context.request.RequestAttributes; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.springframework.web.context.request.RequestContextHolder; | 
					 | 
					 | 
					import org.springframework.web.context.request.RequestContextHolder; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.util.Map; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.concurrent.BlockingQueue; | 
					 | 
					 | 
					import java.util.concurrent.BlockingQueue; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.concurrent.Callable; | 
					 | 
					 | 
					import java.util.concurrent.Callable; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.concurrent.ThreadPoolExecutor; | 
					 | 
					 | 
					import java.util.concurrent.ThreadPoolExecutor; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -35,6 +37,7 @@ import java.util.concurrent.TimeUnit; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					@Component | 
					 | 
					 | 
					@Component | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy { | 
					 | 
					 | 
					public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    public static final ThreadLocal<Map<String, String>> hystrixAdditionHeaders = new ThreadLocal<>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private static final Logger log = LoggerFactory.getLogger(FeignHystrixConcurrencyStrategy.class); | 
					 | 
					 | 
					    private static final Logger log = LoggerFactory.getLogger(FeignHystrixConcurrencyStrategy.class); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private HystrixConcurrencyStrategy delegate; | 
					 | 
					 | 
					    private HystrixConcurrencyStrategy delegate; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -74,8 +77,9 @@ public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    public <T> Callable<T> wrapCallable(Callable<T> callable) { | 
					 | 
					 | 
					    public <T> Callable<T> wrapCallable(Callable<T> callable) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        Map<String, String> inheritableAdditionalHeaders = ThreadLocalConstant.inheritableAdditionalHeaders.get(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); | 
					 | 
					 | 
					        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        return new WrappedCallable<>(callable, requestAttributes); | 
					 | 
					 | 
					        return new WrappedCallable<>(callable, requestAttributes, inheritableAdditionalHeaders); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -105,15 +109,18 @@ public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    static class WrappedCallable<T> implements Callable<T> { | 
					 | 
					 | 
					    static class WrappedCallable<T> implements Callable<T> { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        private final Callable<T> target; | 
					 | 
					 | 
					        private final Callable<T> target; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        private final RequestAttributes requestAttributes; | 
					 | 
					 | 
					        private final RequestAttributes requestAttributes; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        private final Map<String, String> inheritableAdditionalHeaders; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        public WrappedCallable(Callable<T> target, RequestAttributes requestAttributes) { | 
					 | 
					 | 
					        public WrappedCallable(Callable<T> target, RequestAttributes requestAttributes, Map<String, String> inheritableAdditionalHeaders) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            this.target = target; | 
					 | 
					 | 
					            this.target = target; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            this.requestAttributes = requestAttributes; | 
					 | 
					 | 
					            this.requestAttributes = requestAttributes; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            this.inheritableAdditionalHeaders = inheritableAdditionalHeaders; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        @Override | 
					 | 
					 | 
					        @Override | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        public T call() throws Exception { | 
					 | 
					 | 
					        public T call() throws Exception { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            try { | 
					 | 
					 | 
					            try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                hystrixAdditionHeaders.set(inheritableAdditionalHeaders); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                RequestContextHolder.setRequestAttributes(requestAttributes); | 
					 | 
					 | 
					                RequestContextHolder.setRequestAttributes(requestAttributes); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                return target.call(); | 
					 | 
					 | 
					                return target.call(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } finally { | 
					 | 
					 | 
					            } finally { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |