--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/de4d90ef-0d51-487c-8c11-d6b95b18e44e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public class CrawlerVerticle extends AbstractVerticle {
@Override public void start() throws Exception { MetricsService.create(vertx); HttpClientOptions options = new HttpClientOptions().setTcpKeepAlive(false).setConnectTimeout(1000); HttpClient httpClient = vertx.createHttpClient(options); EventBus eventBus = vertx.eventBus(); MessageConsumer<String> consumer = eventBus.consumer("crawl"); consumer.handler(event -> { String url = event.body(); HttpClientRequest request = httpClient.getAbs(url, response -> { if (isSuccess(response)) { response.bodyHandler(buffer -> { String content = buffer.toString(); JsonObject jsonObject = new JsonObject( Json.encode(new UrlInfo(url, content)) ); eventBus.send("parse", jsonObject); }); } else { System.out.println("HTTP FAILURE IN CRAWLER. Status code: " + response.statusCode() + " for URL: " + url); } });
request.exceptionHandler(throwable -> { System.out.println("CRAWLER HTTP CLIENT ERROR!"); throwable.printStackTrace(); });
request.end(); });
consumer.exceptionHandler(throwable -> { System.out.println("CRAWLER ERROR!"); throwable.printStackTrace(); }); }
private boolean isSuccess(HttpClientResponse response) { int statusCode = response.statusCode(); return 200 <= statusCode && statusCode < 400; }}
Feb 25, 2016 12:36:27 PM io.vertx.core.impl.BlockedThreadCheckerWARNING: Thread Thread[vert.x-eventloop-thread-3,5,main] has been blocked for 2196 ms, time limit is 2000Feb 25, 2016 12:36:28 PM io.vertx.core.impl.BlockedThreadCheckerWARNING: Thread Thread[vert.x-eventloop-thread-3,5,main] has been blocked for 3196 ms, time limit is 2000Feb 25, 2016 12:36:29 PM io.vertx.core.impl.BlockedThreadCheckerWARNING: Thread Thread[vert.x-eventloop-thread-3,5,main] has been blocked for 4196 ms, time limit is 2000Feb 25, 2016 12:36:30 PM io.vertx.core.impl.BlockedThreadCheckerWARNING: Thread Thread[vert.x-eventloop-thread-3,5,main] has been blocked for 5197 ms, time limit is 2000io.vertx.core.VertxException: Thread blocked at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) at java.net.InetAddress.getAllByName0(InetAddress.java:1276) at java.net.InetAddress.getAllByName(InetAddress.java:1192) at java.net.InetAddress.getAllByName(InetAddress.java:1126) at java.net.InetAddress.getByName(InetAddress.java:1076) at java.net.InetSocketAddress.<init>(InetSocketAddress.java:220) at io.vertx.core.http.impl.HttpClientImpl.internalConnect(HttpClientImpl.java:749) at io.vertx.core.http.impl.HttpClientImpl.access$000(HttpClientImpl.java:61) at io.vertx.core.http.impl.HttpClientImpl$1.connect(HttpClientImpl.java:93) at io.vertx.core.http.impl.ConnectionManager$ConnQueue.createNewConnection(ConnectionManager.java:173) at io.vertx.core.http.impl.ConnectionManager$ConnQueue.getConnection(ConnectionManager.java:114) at io.vertx.core.http.impl.ConnectionManager.getConnection(ConnectionManager.java:69) at io.vertx.core.http.impl.HttpClientImpl.getConnection(HttpClientImpl.java:674) at io.vertx.core.http.impl.HttpClientRequestImpl.connect(HttpClientRequestImpl.java:586) at io.vertx.core.http.impl.HttpClientRequestImpl.write(HttpClientRequestImpl.java:735) at io.vertx.core.http.impl.HttpClientRequestImpl.end(HttpClientRequestImpl.java:329) at com.volcanodata.vertxpoc.CrawlerVerticle.lambda$start$3(CrawlerVerticle.java:45) at com.volcanodata.vertxpoc.CrawlerVerticle$$Lambda$32/1091876389.handle(Unknown Source) at io.vertx.core.eventbus.impl.HandlerRegistration.handleMessage(HandlerRegistration.java:207) at io.vertx.core.eventbus.impl.HandlerRegistration.handle(HandlerRegistration.java:201) at io.vertx.core.eventbus.impl.EventBusImpl.lambda$deliverToHandler$127(EventBusImpl.java:498) at io.vertx.core.eventbus.impl.EventBusImpl$$Lambda$36/212890971.handle(Unknown Source) at io.vertx.core.impl.ContextImpl.lambda$wrapTask$18(ContextImpl.java:335) at io.vertx.core.impl.ContextImpl$$Lambda$21/1409160703.run(Unknown Source) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) at java.lang.Thread.run(Thread.java:745)
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/58132c20-007d-449b-a53a-aa8c53867077%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/b35a1839-01c6-47d0-814e-301a01d8ed84%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/b7b37bca-6f56-4dd2-9a1b-9f9f3e922837%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/FgI5sf-DAK0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/dc9f4767-a4e3-44eb-9123-0d504aa5044d%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CAOJxNisEHjNgwyv-_ZN_TWUG608kQu5eSuD4Lb6LoPqR83O6uA%40mail.gmail.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/F65F3E61-4E6C-43F6-B79A-554615A958A5%40gmail.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CAOJxNiupVkoEU6%3DM2Tc7zmbKnhMBK3pET5tC%3D7su-C44aza7YA%40mail.gmail.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/4838A84E-94E8-4C11-A0EE-062EF37A124F%40gmail.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CAOJxNisb8pVKvmRO6e1PfjHhpc-k5MaowhMEJfTKwaJAqJAKeQ%40mail.gmail.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/53C5D5AC-3641-4C14-8A54-68A576D51007%40gmail.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CAOJxNiss7%3Ds26P%2B9zx%2BbwE7BPxufHPYVrP4Mr0gMKHBzyALXGw%40mail.gmail.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/56D4B4AE.9080203%40gmail.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CAOJxNit5_FFsv%3D8Sk8KpzLeUTuO7YPGiMhY8EZOwhz-SqaXc0A%40mail.gmail.com.
E.g. hopefully something like this (haven't tested it)
HttpClient client = ...
vertx.executeBlocking(fut -> {
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CAOJxNit6M4W1oZ1L-1cL3sBi1Wm9i%2B%3DhsZ7hCVhn_WLeEZrseg%40mail.gmail.com.