Browse Source

统一网关bug去除

huangzhiyong 7 years ago
parent
commit
31bb3eb266

+ 2 - 2
hos-broker/src/main/resources/application.yml

@ -64,12 +64,12 @@ hos:
spring:
  profiles: test
  activemq:
    broker-url: tcp://172.19.103.37:61616
    broker-url: tcp://172.19.103.42:61616
    user: admin
    password: admin
  data:
    mongodb:
      host: 172.19.103.37
      host: 172.19.103.42
      port: 27017
      username: esb
      password: esb

+ 2 - 2
hos-broker/src/main/resources/logback-spring.xml

@ -18,9 +18,9 @@
    </appender>
    <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">    
        <file>{LOG_HOME}/output.log</file>        
        <file>${LOG_HOME}/output.log</file>        
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>{LOG_HOME}/%d{yyyy-MM-dd_HH_mm}.%i.log.zip</fileNamePattern>
            <fileNamePattern>${LOG_HOME}/%d{yyyy-MM-dd_HH_mm}.%i.log.zip</fileNamePattern>
            <minIndex>1</minIndex>
            <maxIndex>3</maxIndex>
        </rollingPolicy>

+ 2 - 7
hos-camel2/src/main/java/camel/central/gateway/processor/GatewayProcessor.java

@ -193,12 +193,7 @@ public class GatewayProcessor implements Processor {
                url = appApi.getMicroServiceUri();
            }
            final String[] endPoint = {""};
            if (exchange.getIn().getHeader(Exchange.CONTENT_TYPE,String.class).contains("multipart/form-data")){
                endPoint[0] = "jetty:" + url + appApi.getMsMethodName() + "?a=a";
            }else {
                endPoint[0] = "restlet:" + url + appApi.getMsMethodName() + "?socketTimeout=60000&connectionTimeout=60000&restletMethod=" + methodMap.get(appApi.getMethod());
            }
            final String[] endPoint = {"restlet:" + url + appApi.getMsMethodName() + "?socketTimeout=60000&connectionTimeout=60000&restletMethod=" + methodMap.get(appApi.getMethod())};
            final String[] body = {""};
            appApi.getParameters().forEach(p -> {
                JsonNode paramNode = jsonNode.get(p.getName());
@ -256,7 +251,7 @@ public class GatewayProcessor implements Processor {
        //TODO 设置固定的验证入口地址
        HTTPResponse response = HttpClientKit.get(agUrl + "/api/v1.0/admin/apps/" + appKey);
        if (response.getStatusCode() != 200) {
            System.out.println("获取app的secret请求失败!");
            System.out.println("获取app的secret请求失败,status: "+response.getStatusCode() + "error: "+response.getBody());
            return "";
        }

+ 1 - 1
hos-camel2/src/main/java/camel/central/gateway/processor/SignProcessor.java

@ -46,7 +46,7 @@ public class SignProcessor implements Processor {
        //TODO 设置固定的验证入口地址
        HTTPResponse response = HttpClientKit.get(agUrl + "/api/v1.0/admin/apps/" + appKey);
        if (response.getStatusCode() != 200) {
            System.out.println("获取app的secret请求失败!");
            System.out.println("获取app的secret请求失败,status: "+response.getStatusCode() + "error: "+response.getBody());
            return "";
        }

+ 1 - 3
hos-camel2/src/main/java/camel/central/gateway/route/GatewayRouterBuilder.java

@ -68,9 +68,7 @@ public class GatewayRouterBuilder extends RouteBuilder {
//                .endChoice();
        //统一网关入口(restful)
        from("jetty:http://0.0.0.0:9999/api?bridgeEndpoint=true&enableMultipartFilter=false").routeId("api")
                .setHeader("User-Agent", header("UserAgent"))//使用postman测试时,无法设置User-Agent,使用UserAgent来获取
                .removeHeaders("CamelHttp*")
        from("jetty:http://0.0.0.0:9999/api").routeId("api")
                .process(new GatewayProcessor())
                .routingSlip(method(GatewayProcessor.class, "route"));