Я пытаюсь проанализировать CSV-файл и выполнить почтовый вызов, вот чего я достиг:
public static void main(String[] argc) {
Vertx vertx = Vertx.vertx();
WebClientOptions options = new WebClientOptions();
WebClient client = WebClient.create(vertx, options);
String uri = "/api/command";
String host = "mydomain";
vertx.fileSystem().rxReadFile("file.csv")
.flattenAsObservable(fileContent -> Lists.newArrayList(fileContent.toString().split("\n")))
.map(row -> row.split(";"))
.skip(1)
.map(row -> new JsonObject().put(name, row[0]))
.flatMap(row -> {
createCmd.put("CMD","CMD")
return client.post(host,uri)
.rxSendJson(createCmd)
.map((HttpResponse<Buffer> r) -> {
Long res = r.bodyAsJsonObject()
.getJsonObject("result")
.getJsonArray("hits")
.getJsonObject(0)
.getLong("res");
return row.put("res", res);
}).toObservable();
})
.doOnComplete(() -> System.out.println("On Complete: Completed the operation"))
.doOnTerminate(() -> System.out.println("On Terminate: Terminated the operation"))
.subscribe(
content -> System.out.println("Content: " + content),
err -> System.out.println("Cannot read the file: " + err.getMessage())
);
System.out.println("Out of the Vertx Read Stream");
}
Почему этот код никогда не достигает последней строки?
System.out.println("Out of the Vertx Read Stream");
Блокирую ли я каким-либо образом выполнение потока, и он застревает или это нормальное поведение?
РЕДАКТИРОВАТЬ:
Я также получаю это предупреждение
Apr 10, 2020 5:57:51 PM io.vertx.core.impl.BlockedThreadChecker
WARNING: Thread Thread[vert.x-worker-thread-5,5,main]=Thread[vert.x-worker-thread-5,5,main] has been blocked for 75944 ms, time limit is 60000 ms
io.vertx.core.VertxException: Thread blocked