DubboFilterFactory 没反映
This commit is contained in:
parent
fb6382a57a
commit
f9da760e8d
|
@ -17,10 +17,13 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
|
|
||||||
|
import cn.ecpark.service.usergw.biz.filters.bean.GenericServicePool;
|
||||||
import io.netty.util.Recycler;
|
import io.netty.util.Recycler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@Slf4j
|
||||||
public class DubboFilter implements GlobalFilter, Ordered {
|
public class DubboFilter implements GlobalFilter, Ordered {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -31,25 +34,46 @@ public class DubboFilter implements GlobalFilter, Ordered {
|
||||||
return Ordered.LOWEST_PRECEDENCE;
|
return Ordered.LOWEST_PRECEDENCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReferenceConfigCache cache = ReferenceConfigCache.getCache();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||||
// exchange.getRequest();
|
// exchange.getRequest();
|
||||||
|
|
||||||
|
String application = "dubbo-exchange"; // 必须
|
||||||
|
// reference.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
|
||||||
|
String rgroup = "group";
|
||||||
|
String rinterface = "ocean.demo.api.IExchange"; // 弱类型接口名 必须
|
||||||
|
String rversion = "1.0.0";
|
||||||
|
String rmethod = "Say";
|
||||||
|
|
||||||
|
|
||||||
|
String rkey = "";
|
||||||
|
rkey += application;
|
||||||
|
|
||||||
|
if(rgroup != ""){
|
||||||
|
rkey += "/" + rgroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
rkey += "/" + rinterface;
|
||||||
|
rkey += ":" + rversion;
|
||||||
|
|
||||||
|
GenericServicePool gsPool = appContext.getBean(GenericServicePool.class);
|
||||||
|
if(!gsPool.contains(rkey)) {
|
||||||
|
|
||||||
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); // 该实例很重量,里面封装了所有与注册中心及服务提供方连接,请缓存
|
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); // 该实例很重量,里面封装了所有与注册中心及服务提供方连接,请缓存
|
||||||
|
|
||||||
reference.setApplication(new ApplicationConfig("dubbo-exchange"));
|
reference.setApplication(new ApplicationConfig(application)); // 必须
|
||||||
// reference.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
|
// reference.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
|
||||||
reference.setGroup("group");
|
// reference.setGroup("group");
|
||||||
reference.setInterface("ocean.demo.api.IExchange"); // 弱类型接口名
|
reference.setInterface(rinterface); // 弱类型接口名 必须
|
||||||
reference.setVersion("1.0.0");
|
reference.setVersion(rversion); // 必须
|
||||||
reference.setGeneric(true); // 声明为泛化接口
|
reference.setGeneric(true); // 声明为泛化接口
|
||||||
|
|
||||||
Recycler a;
|
gsPool.add(rkey, reference.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
GenericService gs = gsPool.get(rkey);
|
||||||
|
|
||||||
GenericService gs = cache.get(reference);
|
Object result = gs.$invoke(rmethod, new String[] {"java.lang.String"}, new Object[] {"213"});
|
||||||
Object result = gs.$invoke("Hello", new String[] {}, new Object[] {});
|
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
ServerHttpResponse response = exchange.getResponse();
|
ServerHttpResponse response = exchange.getResponse();
|
||||||
|
|
|
@ -21,9 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
public class GenericServicePool {
|
public class GenericServicePool {
|
||||||
|
|
||||||
private class GenericServiceManager {
|
private class GenericServiceManager {
|
||||||
|
|
||||||
Lock idleLock = new ReentrantLock();
|
Lock idleLock = new ReentrantLock();
|
||||||
|
|
||||||
LinkedList<GenericService> idle = new LinkedList<>();
|
LinkedList<GenericService> idle = new LinkedList<>();
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
@ -59,6 +57,7 @@ public class GenericServicePool {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
|
log.error("悠闲队列出现问题: " + e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
idleLock.unlock();
|
idleLock.unlock();
|
||||||
}
|
}
|
||||||
|
@ -72,6 +71,8 @@ public class GenericServicePool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public GenericServiceManager() {
|
public GenericServiceManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,4 +100,7 @@ public class GenericServicePool {
|
||||||
pool.add(genericService);
|
pool.add(genericService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean contains(String key) {
|
||||||
|
return gsDictionary.containsKey(key);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
package cn.ecpark.service.usergw.biz.filters.factory;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
|
import org.apache.dubbo.config.ApplicationConfig;
|
||||||
|
import org.apache.dubbo.config.ReferenceConfig;
|
||||||
|
import org.apache.dubbo.rpc.service.GenericService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||||
|
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import cn.ecpark.service.usergw.biz.filters.bean.GenericServicePool;
|
||||||
|
import reactor.core.publisher.Mono;;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class DubboFilterFactory extends AbstractGatewayFilterFactory<DubboFilterFactory.Config> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext appContext;
|
||||||
|
|
||||||
|
public DubboFilterFactory() {
|
||||||
|
super(Config.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GatewayFilter apply(Config config) {
|
||||||
|
String dubboUri = config.dubboUri;
|
||||||
|
|
||||||
|
return (exchange, chain) -> {
|
||||||
|
|
||||||
|
String application = "dubbo-exchange"; // 必须
|
||||||
|
// reference.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
|
||||||
|
String rgroup = "group";
|
||||||
|
String rinterface = "ocean.demo.api.IExchange"; // 弱类型接口名 必须
|
||||||
|
String rversion = "1.0.0";
|
||||||
|
String rmethod = "Say";
|
||||||
|
List<String> rparamTypes = new ArrayList<String>();
|
||||||
|
List<String> rparams = new ArrayList<String>();
|
||||||
|
|
||||||
|
|
||||||
|
String rkey = "";
|
||||||
|
rkey += application;
|
||||||
|
|
||||||
|
if(rgroup != ""){
|
||||||
|
rkey += "/" + rgroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
rkey += "/" + rinterface;
|
||||||
|
rkey += ":" + rversion;
|
||||||
|
|
||||||
|
GenericServicePool gsPool = appContext.getBean(GenericServicePool.class);
|
||||||
|
if(!gsPool.contains(rkey)) {
|
||||||
|
|
||||||
|
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); // 该实例很重量,里面封装了所有与注册中心及服务提供方连接,请缓存
|
||||||
|
|
||||||
|
reference.setApplication(new ApplicationConfig("dubbo-exchange")); // 必须
|
||||||
|
// reference.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
|
||||||
|
reference.setGroup("group");
|
||||||
|
reference.setInterface("ocean.demo.api.IExchange"); // 弱类型接口名 必须
|
||||||
|
reference.setVersion("1.0.0"); // 必须
|
||||||
|
reference.setGeneric(true); // 声明为泛化接口
|
||||||
|
|
||||||
|
gsPool.add(rkey, reference.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
GenericService gs = gsPool.get(rkey);
|
||||||
|
Object result = gs.$invoke("Hello", new String[] {}, new Object[] {});
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
ServerHttpResponse response = exchange.getResponse();
|
||||||
|
return response.writeWith(
|
||||||
|
Mono.just(response.bufferFactory().wrap(ByteBuffer.wrap(JSON.toJSONString(result).getBytes()))));
|
||||||
|
}
|
||||||
|
return chain.filter(exchange);
|
||||||
|
|
||||||
|
// gs.$invoke(method, parameterTypes, args)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class Config {
|
||||||
|
|
||||||
|
private String dubboUri;
|
||||||
|
|
||||||
|
public String getDubboUri() {
|
||||||
|
return dubboUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDubboUri(String dubboUri) {
|
||||||
|
this.dubboUri = dubboUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -16,13 +16,13 @@ import org.springframework.cloud.gateway.handler.predicate.PredicateDefinition;
|
||||||
import org.springframework.cloud.gateway.route.RouteDefinition;
|
import org.springframework.cloud.gateway.route.RouteDefinition;
|
||||||
import org.springframework.cloud.gateway.route.RouteDefinitionLocator;
|
import org.springframework.cloud.gateway.route.RouteDefinitionLocator;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.reactive.result.method.RequestMappingInfo;
|
|
||||||
import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping;
|
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
import cn.ecpark.service.usergw.biz.filters.bean.GenericServicePool;
|
||||||
|
import cn.ecpark.service.usergw.biz.filters.factory.DubboFilterFactory;
|
||||||
import cn.ecpark.service.usergw.impl.http.Http2Dubbo;
|
import cn.ecpark.service.usergw.impl.http.Http2Dubbo;
|
||||||
import cn.ecpark.service.usergw.utils.Convert;
|
import cn.ecpark.service.usergw.utils.Convert;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -38,9 +38,21 @@ public class ConfigGateway implements RouteDefinitionLocator {
|
||||||
|
|
||||||
// List<MediaType> mediaTypes = new ArrayList<>();
|
// List<MediaType> mediaTypes = new ArrayList<>();
|
||||||
|
|
||||||
|
List<FilterDefinition> defaultFilters;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public GenericServicePool genericServicePool() {
|
||||||
|
return new GenericServicePool();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DubboFilterFactory dubboFilterFactory() {
|
||||||
|
return new DubboFilterFactory();
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Http2Dubbo http2Dubbo;
|
private Http2Dubbo http2Dubbo;
|
||||||
|
|
||||||
|
@ -76,35 +88,37 @@ public class ConfigGateway implements RouteDefinitionLocator {
|
||||||
// log.error(e.toString());
|
// log.error(e.toString());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Map<String, Object> configDefault = (Map<String, Object>) configYaml.get("default");
|
Map<String, Object> defaultYaml = (Map<String, Object>) configYaml.get("default");
|
||||||
Map<String, Object> configDubbo = (Map<String, Object>) configYaml.get("dubbo");
|
Map<String, Object> dubboYaml = (Map<String, Object>) configYaml.get("dubbo");
|
||||||
|
|
||||||
if ( configDubbo != null && !configDubbo.isEmpty()) {
|
List<RouteDefinition> routeList = new ArrayList<RouteDefinition>();
|
||||||
this.createHttp2Dubbo(configDubbo);
|
|
||||||
|
if (defaultYaml != null && !defaultYaml.isEmpty()) {
|
||||||
|
defaultFilters = this.getDefaultFilter(defaultYaml);
|
||||||
|
this.configDefault(routeList, defaultYaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dubboYaml != null && !dubboYaml.isEmpty()) {
|
||||||
|
this.configHttp2Dubbo(routeList, dubboYaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!routeList.isEmpty()) {
|
||||||
|
return Flux.fromIterable(routeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( configDefault != null && !configDefault.isEmpty()) {
|
|
||||||
List<RouteDefinition> result = this.getConfigDefault(configDefault);
|
|
||||||
if (result != null ) {
|
|
||||||
return Flux.fromIterable(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Flux.empty();
|
return Flux.empty();
|
||||||
// return Flux.fromIterable(it);
|
// return Flux.fromIterable(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private List<RouteDefinition> getConfigDefault(Map<String, Object> configDefault) {
|
private List<FilterDefinition> getDefaultFilter(Map<String, Object> defaultYaml) {
|
||||||
if (configDefault != null) {
|
|
||||||
List<RouteDefinition> RDList = new ArrayList<>();
|
|
||||||
|
|
||||||
List<FilterDefinition> filters = new ArrayList<>();
|
List<FilterDefinition> filters = new ArrayList<>();
|
||||||
List<PredicateDefinition> predicates = new ArrayList<>();
|
|
||||||
|
|
||||||
// default-filters: 下的相关设置
|
// default-filters: 下的相关设置
|
||||||
Object unknownDefaultFilters = configDefault.get("default-filters");
|
Object unknownDefaultFilters = defaultYaml.get("default-filters");
|
||||||
if (unknownDefaultFilters != null) {
|
if (unknownDefaultFilters != null) {
|
||||||
List<String> defaultFiltersYaml = (ArrayList<String>) unknownDefaultFilters;
|
List<String> defaultFiltersYaml = (ArrayList<String>) unknownDefaultFilters;
|
||||||
for (String filterString : defaultFiltersYaml) {
|
for (String filterString : defaultFiltersYaml) {
|
||||||
|
@ -112,12 +126,24 @@ public class ConfigGateway implements RouteDefinitionLocator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object unknownRoutes = configDefault.get("routes");
|
return filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void configDefault(List<RouteDefinition> routeList, Map<String, Object> defaultYaml) {
|
||||||
|
if (defaultYaml != null) {
|
||||||
|
|
||||||
|
Object unknownRoutes = defaultYaml.get("routes");
|
||||||
if (unknownRoutes != null) {
|
if (unknownRoutes != null) {
|
||||||
List<LinkedHashMap<String, List<String>>> routes = (ArrayList<LinkedHashMap<String, List<String>>>) unknownRoutes;
|
List<LinkedHashMap<String, List<String>>> routes = (ArrayList<LinkedHashMap<String, List<String>>>) unknownRoutes;
|
||||||
for (LinkedHashMap<String, List<String>> iter : routes) {
|
for (LinkedHashMap<String, List<String>> iter : routes) {
|
||||||
|
|
||||||
|
List<FilterDefinition> filters = new ArrayList<>();
|
||||||
|
List<PredicateDefinition> predicates = new ArrayList<>();
|
||||||
RouteDefinition rd = new RouteDefinition();
|
RouteDefinition rd = new RouteDefinition();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 设置基础属性
|
// 设置基础属性
|
||||||
this.ParseAndSetBase(rd, iter);
|
this.ParseAndSetBase(rd, iter);
|
||||||
|
|
||||||
|
@ -130,14 +156,10 @@ public class ConfigGateway implements RouteDefinitionLocator {
|
||||||
rd.setPredicates(predicates);
|
rd.setPredicates(predicates);
|
||||||
rd.setFilters(filters);
|
rd.setFilters(filters);
|
||||||
|
|
||||||
RDList.add(rd);
|
routeList.add(rd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RDList;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseAndSetBase(RouteDefinition rd, LinkedHashMap<String, List<String>> iter) {
|
private void ParseAndSetBase(RouteDefinition rd, LinkedHashMap<String, List<String>> iter) {
|
||||||
|
@ -160,7 +182,8 @@ public class ConfigGateway implements RouteDefinitionLocator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseAndAddPredicates(List<PredicateDefinition> predicates, LinkedHashMap<String, List<String>> iter, String yamlField) {
|
private void ParseAndAddPredicates(List<PredicateDefinition> predicates, LinkedHashMap<String, List<String>> iter,
|
||||||
|
String yamlField) {
|
||||||
List<String> predicatesYaml = iter.get(yamlField);
|
List<String> predicatesYaml = iter.get(yamlField);
|
||||||
if (predicatesYaml != null) {
|
if (predicatesYaml != null) {
|
||||||
for (String predicateString : predicatesYaml) {
|
for (String predicateString : predicatesYaml) {
|
||||||
|
@ -169,25 +192,53 @@ public class ConfigGateway implements RouteDefinitionLocator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseAndAddFilters(List<FilterDefinition> filters, LinkedHashMap<String, List<String>> iter, String yamlField) {
|
private void ParseAndAddFilters(List<FilterDefinition> filters, LinkedHashMap<String, List<String>> iter,
|
||||||
|
String yamlField) {
|
||||||
List<String> filtersYaml = iter.get(yamlField);
|
List<String> filtersYaml = iter.get(yamlField);
|
||||||
if (filtersYaml != null) {
|
if (filtersYaml != null) {
|
||||||
|
filters.addAll(defaultFilters);
|
||||||
for (String filterString : filtersYaml) {
|
for (String filterString : filtersYaml) {
|
||||||
filters.add(new FilterDefinition(filterString));
|
filters.add(new FilterDefinition(filterString));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void configHttp2Dubbo(List<RouteDefinition> routeList, Map<String, Object> configDubbo) {
|
||||||
private void createHttp2Dubbo(Map<String, Object> configDubbo) {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
RequestMappingHandlerMapping requestMapping = (RequestMappingHandlerMapping) applicationContext
|
Object unknownRoutes = configDubbo.get("routes");
|
||||||
.getBean("requestMappingHandlerMapping");
|
if (unknownRoutes != null) {
|
||||||
|
GenericServicePool pool = applicationContext.getBean(GenericServicePool.class);
|
||||||
|
|
||||||
requestMapping.registerMapping(RequestMappingInfo.paths("/test/xixi").methods(RequestMethod.POST).build(),
|
List<LinkedHashMap<String, List<String>>> routes = (ArrayList<LinkedHashMap<String, List<String>>>) unknownRoutes;
|
||||||
http2Dubbo, Http2Dubbo.class.getDeclaredMethod("H2DTest"));
|
for (LinkedHashMap<String, List<String>> iter : routes) {
|
||||||
|
|
||||||
|
List<FilterDefinition> filters = new ArrayList<>();
|
||||||
|
List<PredicateDefinition> predicates = new ArrayList<>();
|
||||||
|
RouteDefinition rd = new RouteDefinition();
|
||||||
|
|
||||||
|
this.ParseAndSetBase(rd, iter);
|
||||||
|
|
||||||
|
// 设置基础属性
|
||||||
|
this.ParseAndSetBase(rd, iter);
|
||||||
|
|
||||||
|
// predicates: 下的相关属性
|
||||||
|
this.ParseAndAddPredicates(predicates, iter, "predicates");
|
||||||
|
|
||||||
|
// filters: 下的相关属性
|
||||||
|
this.ParseAndAddFilters(filters, iter, "filters");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// RequestMappingHandlerMapping requestMapping = (RequestMappingHandlerMapping)
|
||||||
|
// applicationContext
|
||||||
|
// .getBean("requestMappingHandlerMapping");
|
||||||
|
|
||||||
|
// requestMapping.registerMapping(RequestMappingInfo.paths("/test/xixi").methods(RequestMethod.POST).build(),
|
||||||
|
// http2Dubbo, Http2Dubbo.class.getDeclaredMethod("H2DTest"));
|
||||||
|
|
||||||
// 引用远程服务
|
// 引用远程服务
|
||||||
// try {
|
// try {
|
||||||
|
@ -201,6 +252,7 @@ public class ConfigGateway implements RouteDefinitionLocator {
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: 任何错误都直接终止退出
|
// TODO: 任何错误都直接终止退出
|
||||||
|
log.error(e.toString());
|
||||||
SpringApplication.exit(applicationContext);
|
SpringApplication.exit(applicationContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,14 @@ default:
|
||||||
dubbo:
|
dubbo:
|
||||||
routes:
|
routes:
|
||||||
- id: test
|
- id: test
|
||||||
path: /dubbo/hello
|
order: 10
|
||||||
|
application: dubbo-exchange
|
||||||
|
uri: http://httpbin.org:80/get
|
||||||
|
# path: /dubbo/hello
|
||||||
interface: ocean.demo.api.IExchange
|
interface: ocean.demo.api.IExchange
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
predicates:
|
||||||
|
- Path=/dubbo/hello
|
||||||
|
filters:
|
||||||
|
- Dubbo=234
|
||||||
|
|
Loading…
Reference in New Issue
Block a user