Commit c3ae5901 by Nepxion

升级版本到4.8.2.4

parent eed7edce
......@@ -705,7 +705,7 @@ spring.application.strategy.scan.packages=com.nepxion.discovery.plugin.example.s
# 启动和关闭用户自定义和编程灰度路由策略的时候,对REST方式的调用拦截。缺失则默认为false
spring.application.strategy.rest.intercept.enabled=true
# 用户自定义和编程灰度路由策略的时候,对REST方式调用拦截的时候(支持Feign或者RestTemplate调用),需要把来自外部的指定Header参数传递到服务里,如果多个用“;”分隔,不允许出现空格。该项配置只对服务有效,对网关无效
spring.application.strategy.request.headers=version;region;address;token
spring.application.strategy.request.headers=token
# 启动和关闭用户自定义和编程灰度路由策略的时候日志打印,注意每调用一次都会打印一次,会对性能有所影响,建议压测环境和生产环境关闭。缺失则默认为false
spring.application.strategy.intercept.log.print=true
# 开启服务端实现Hystrix线程隔离模式做服务隔离时,必须把spring.application.strategy.hystrix.threadlocal.supported设置为true,同时要引入discovery-plugin-strategy-starter-hystrix包,否则线程切换时会发生ThreadLocal上下文对象丢失
......
......@@ -12,6 +12,7 @@ package com.nepxion.discovery.plugin.strategy.service.aop;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
......@@ -45,6 +46,17 @@ public class FeignStrategyInterceptor implements RequestInterceptor {
LOG.info("------------- Feign Intercept Information -----------");
if (StringUtils.isNotEmpty(requestHeaders)) {
requestHeaderList = StringUtil.splitToList(requestHeaders.toLowerCase(), DiscoveryConstant.SEPARATE);
} else {
requestHeaderList = new ArrayList<String>();
}
if (!requestHeaderList.contains(DiscoveryConstant.VERSION)) {
requestHeaderList.add(DiscoveryConstant.VERSION);
}
if (!requestHeaderList.contains(DiscoveryConstant.REGION)) {
requestHeaderList.add(DiscoveryConstant.REGION);
}
if (!requestHeaderList.contains(DiscoveryConstant.ADDRESS)) {
requestHeaderList.add(DiscoveryConstant.ADDRESS);
}
LOG.info("Feign intercepted headers are {}", StringUtils.isNotEmpty(requestHeaders) ? requestHeaders : "empty");
LOG.info("-------------------------------------------------");
......
......@@ -10,6 +10,7 @@ package com.nepxion.discovery.plugin.strategy.service.aop;
*/
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
......@@ -48,6 +49,17 @@ public class RestTemplateStrategyInterceptor implements ClientHttpRequestInterce
LOG.info("------------- RestTemplate Intercept Information -----------");
if (StringUtils.isNotEmpty(requestHeaders)) {
requestHeaderList = StringUtil.splitToList(requestHeaders.toLowerCase(), DiscoveryConstant.SEPARATE);
} else {
requestHeaderList = new ArrayList<String>();
}
if (!requestHeaderList.contains(DiscoveryConstant.VERSION)) {
requestHeaderList.add(DiscoveryConstant.VERSION);
}
if (!requestHeaderList.contains(DiscoveryConstant.REGION)) {
requestHeaderList.add(DiscoveryConstant.REGION);
}
if (!requestHeaderList.contains(DiscoveryConstant.ADDRESS)) {
requestHeaderList.add(DiscoveryConstant.ADDRESS);
}
LOG.info("RestTemplate intercepted headers are {}", StringUtils.isNotEmpty(requestHeaders) ? requestHeaders : "empty");
LOG.info("-------------------------------------------------");
......
......@@ -93,7 +93,7 @@ spring.application.strategy.scan.packages=com.nepxion.discovery.plugin.example.s
# 启动和关闭用户自定义和编程灰度路由策略的时候,对REST方式的调用拦截。缺失则默认为false
spring.application.strategy.rest.intercept.enabled=true
# 用户自定义和编程灰度路由策略的时候,对REST方式调用拦截的时候(支持Feign或者RestTemplate调用),需要把来自外部的指定Header参数传递到服务里,如果多个用“;”分隔,不允许出现空格。该项配置只对服务有效,对网关无效
spring.application.strategy.request.headers=version;region;address;token
spring.application.strategy.request.headers=token
# 启动和关闭用户自定义和编程灰度路由策略的时候日志打印,注意每调用一次都会打印一次,会对性能有所影响,建议压测环境和生产环境关闭。缺失则默认为false
spring.application.strategy.intercept.log.print=true
# 开启服务端实现Hystrix线程隔离模式做服务隔离时,必须把spring.application.strategy.hystrix.threadlocal.supported设置为true,同时要引入discovery-plugin-strategy-starter-hystrix包,否则线程切换时会发生ThreadLocal上下文对象丢失
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment