vertx 代码不执行
public class SendUrlToSaas { private static Vertx vertx = Vertx.vertx(); private Logger logger = LoggerFactory.getLogger(SendUrlToSaas.class.getName()); private final static String JKS_NAME = "fxiaoke.jks"; public void sendUrl(){ String requestHeader = getFileMessage("requestHeader"); String requestBody = getFileMessage("requestBody"); /* * 缺少判断 */ if(null == requestHeader){ logger.debug("Can't read file of url.template "); return; } JsonObject jsonHeader = new JsonObject(requestHeader); HttpClientOptions options = new HttpClientOptions().setKeyStoreOptions(getCustomJksOption()) .setSsl(true).setTrustAll(true).setDefaultPort(443).setVerifyHost(false); HttpClient httpClient = vertx.createHttpClient(options); HttpClientRequest request = httpClient.request(HttpMethod.POST, 443, jsonHeader.getString("Host"), jsonHeader.getString("url"), responseHandler->{ System.err.println("执行到了这儿了!"); /*MultiMap map = responseHandler.trailers(); List<Map.Entry<String,String>> list = map.entries(); for(Map.Entry<String, String> me:list){ System.out.println(me.getKey()); System.out.println(me.getValue()); }*/ /*responseHandler.bodyHandler(body->{ try { System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); System.out.println("输出为"+body.toString()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } });*/ }); Iterator<Map.Entry<String, Object>> it = jsonHeader.iterator(); while(it.hasNext()){ Map.Entry<String,Object> map = it.next(); request.putHeader(map.getKey(), (String)map.getValue()); } request.putHeader("Expect", "100-Continue"); request.continueHandler(v ->{ System.err.println("--------->>>>>>>>>>>>>>>>>>>>."); request.write(requestBody); request.end(); }); // request.end(); }
我的这段代码总是不执行
request.continueHandler(v ->{ System.err.println("--------->>>>>>>>>>>>>>>>>>>>."); request.write(requestBody); request.end(); });
括号里面的三行代码,哪位大神可以给我指导一下!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题解决了,版本太旧了的问题,
改成这样就可以了