SpringCloud Feign session传递 forward Header ###一、hystrix配置为SEMAPHORE 模式
hystrix: command: default: execution: isolation: strategy: SEMAPHORE semaphore: timeoutInMilliseconds: 3000
###二、FeignClients增加 RequestInterceptor
自定义 FeignClientsConfiguration如下
@Configurationpublic class FeignClientsConfigurationCustom { @Bean public RequestInterceptor headerInterceptor() { return new RequestInterceptor() { @Override public void apply(RequestTemplate requestTemplate) { HttpServletRequest request = RequestUtils.getRequest(); EnumerationheaderNames = request.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { String name = headerNames.nextElement(); Enumeration values = request.getHeaders(name); while (values.hasMoreElements()) { String value = values.nextElement(); requestTemplate.header(name, value); } } } } }; }