瀏覽代碼

restlet connetionTimeOut

huangzhiyong 8 年之前
父節點
當前提交
0f9e158818
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      hos-camel2/src/main/java/camel/gateway/processor/GatewayProcessor.java

+ 5 - 4
hos-camel2/src/main/java/camel/gateway/processor/GatewayProcessor.java

@ -168,12 +168,12 @@ public class GatewayProcessor implements Processor {
            JsonNode jsonNode = objectMapper.readValue(param, JsonNode.class);
            String url = appApi.getMicroServiceUri().split(",")[0];
            String endPoint = "restlet:" + url + appApi.getMsMethodName() + "restletMethods=" + 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 -> {
                String value = jsonNode.asText(p.getName());
                String value = jsonNode.get(p.getName()).asText();
                if (p.getType().equals("0")) { //path param
                    endPoint.replace("{" + p.getName() + "}", value);
                    endPoint[0] = endPoint[0].replaceAll("\\{[^}]*\\}", value);
                }
                body[0] += ("&" + p.getName() + "=" + value);
@ -183,6 +183,7 @@ public class GatewayProcessor implements Processor {
            if (body[0].length() != 0) {
                exchange.getOut().setBody(body[0].substring(1));
            }
            return endPoint[0];
        } catch (IOException e) {
            e.printStackTrace();
        }
@ -195,7 +196,7 @@ public class GatewayProcessor implements Processor {
            return appApi;
        }
        HTTPResponse response = HttpClientKit.get("http://localhost:10000/api/v1.0/admin/appApi/search?filters=msMethodName%3D" + api + "&size=15&page=1");
        HTTPResponse response = HttpClientKit.get("http://localhost:10000/api/v1.0/admin/appApi/search?filters=methodName%3D" + api + "&size=15&page=1");
        if (response.getStatusCode() != 200) {
            return null;
        }