|
@@ -1,10 +1,14 @@
|
|
|
package cn.vbdsm.hj212.modbus.utils;
|
|
package cn.vbdsm.hj212.modbus.utils;
|
|
|
|
|
+
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.cxf.endpoint.Client;
|
|
import org.apache.cxf.endpoint.Client;
|
|
|
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
|
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
|
|
import org.apache.cxf.transport.http.HTTPConduit;
|
|
import org.apache.cxf.transport.http.HTTPConduit;
|
|
|
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
|
|
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class WsClientUtil {
|
|
public class WsClientUtil {
|
|
|
public static String callWebSV(String wsdUrl, String operationName, String... params){
|
|
public static String callWebSV(String wsdUrl, String operationName, String... params){
|
|
@@ -12,7 +16,7 @@ public class WsClientUtil {
|
|
|
Client client = dcf.createClient(wsdUrl);
|
|
Client client = dcf.createClient(wsdUrl);
|
|
|
HTTPConduit conduit = (HTTPConduit) client.getConduit();
|
|
HTTPConduit conduit = (HTTPConduit) client.getConduit();
|
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
- long timeout = 10 * 1000;// 60s timeout
|
|
|
|
|
|
|
+ long timeout = 10 * 1000;// 10s timeout
|
|
|
policy.setConnectionTimeout(timeout);
|
|
policy.setConnectionTimeout(timeout);
|
|
|
policy.setReceiveTimeout(timeout);
|
|
policy.setReceiveTimeout(timeout);
|
|
|
conduit.setClient(policy);
|
|
conduit.setClient(policy);
|
|
@@ -27,4 +31,29 @@ public class WsClientUtil {
|
|
|
return "发送错误!请检查日志记录!";
|
|
return "发送错误!请检查日志记录!";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+// public static void main(String[] args){
|
|
|
|
|
+// initFlowRules();
|
|
|
|
|
+// while (true) {
|
|
|
|
|
+// // 1.5.0 版本开始可以直接利用 try-with-resources 特性
|
|
|
|
|
+// try (Entry entry = SphU.entry("HelloWorld")) {
|
|
|
|
|
+// // 被保护的逻辑
|
|
|
|
|
+// System.out.println("hello world");
|
|
|
|
|
+// } catch (BlockException ex) {
|
|
|
|
|
+// // 处理被流控的逻辑
|
|
|
|
|
+// System.out.println("blocked!");
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// public static void initFlowRules(){
|
|
|
|
|
+// List<FlowRule> rules = new ArrayList<>();
|
|
|
|
|
+// FlowRule rule = new FlowRule();
|
|
|
|
|
+// rule.setResource("HelloWorld");
|
|
|
|
|
+// rule.setGrade(RuleConstant.FLOW_GRADE_QPS);
|
|
|
|
|
+// rule.setCount(20);
|
|
|
|
|
+// rules.add(rule);
|
|
|
|
|
+// FlowRuleManager.loadRules(rules);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
}
|
|
}
|