Last active
December 26, 2015 03:29
-
-
Save kaushalpanjwani/7086586 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.log4j.Logger; | |
import org.vertx.java.core.Handler; | |
import org.vertx.java.core.buffer.Buffer; | |
import org.vertx.java.core.http.HttpClient; | |
import org.vertx.java.core.http.HttpClientResponse; | |
import org.vertx.java.platform.Verticle; | |
public class TestVertHangingVerticle extends Verticle{ | |
private final Logger logger = Logger.getLogger(TestVertHangingVerticle.class); | |
@Override | |
public void start() { | |
final HttpClient client = vertx.createHttpClient().setHost(PropertyFileHelper.getValue("my.host")); | |
client.setSSL(true); | |
client.setPort(443); | |
client.setTrustAll(true); | |
//client.setKeepAlive(false); | |
//client.setMaxPoolSize(2); | |
//client.setConnectTimeout(1000); | |
long timerID = vertx.setPeriodic(300000, new Handler<Long>() { | |
public void handle(Long timerID) { | |
fetchSession(client); | |
} | |
}); | |
} | |
private void fetchSession(final HttpClient client) { | |
String queryString = "my query string"; | |
logger.trace("Calling service : " + queryString); | |
client.getNow(queryString, new Handler<HttpClientResponse>() { | |
public void handle(HttpClientResponse resp) { | |
resp.bodyHandler(new Handler<Buffer>() { | |
public void handle(Buffer data) { | |
String responseBody = new String(data.getBytes()); | |
logger.debug("response: " + responseBody); | |
} | |
}); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment