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