Hi All,
Please help me as I am new on Vert.x .
In
httpclient my response come late , till the time request block is
executed and response set is NULL but later it will print into CONSOLE. HttpClientOptions options = new HttpClientOptions().setKeepAlive(false);
options.setLogActivity(true);
options.setDefaultHost("delvmpllbbab10");
options.setDefaultPort(7003);
HttpClient client = vertx.createHttpClient(options);
String[] resp = {null};
client.request(HttpMethod.GET, "/rcsservices/homePage", response -> {
response.handler(buffer -> {
System.out.println("Received a part of the response body: " + buffer);
resp[0] = buffer.toString();
});
}).putHeader("content-type", "application/json").end(Json.encodePrettily(resp[0]));
System.out.println(resp[0]);
OUPUT in CONSOLE :
null (means this line going to print first " System.out.println(resp[0]);" which is out of request body);
Received a part of the response body: {"contents":} (later my response came "System.out.println("Received a part of the response body: " + buffer);" )
Unable to understand whats going on., Help me .
Thanks,
Yogesh Kumar Bholan