Created
February 25, 2019 15:28
-
-
Save yeziyezi/4b16b6cb4b6ed9817653993d0e2fc19c to your computer and use it in GitHub Desktop.
Vert.x batch demo
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
vertx.executeBlocking(future -> { | |
mysqlClient.getConnection(r -> { | |
List<String> list = new ArrayList<>(); | |
//向list中添加五个sql语句 | |
for (int i = 0; i < 5; i++) { | |
list.add("insert into md2html (uuid,file_path,alive_time) values " + | |
"('" + UUID.randomUUID().toString() + "'" + | |
",'/var/folders/0l/hf59_p4150zfm0z5p1_njhjm0000gn/T/fb54cf" + | |
"08-acc4-40bc-a9d8-75ab73441d08463909208420264947/" + | |
"1.html','2019-02-25 21:18:09')"); | |
} | |
//同样的sql语句,单独update可以成功执行到future.complete() | |
// r.result().update("........", res1 -> { | |
// LoggerFactory.getLogger("demo").info(res1.succeeded()); | |
// future.complete(); | |
// }); | |
//等待很久依然执行不到回调函数 | |
r.result().batch(list, res1 -> { | |
LoggerFactory.getLogger("demo").info(res1.succeeded()); | |
future.complete(); | |
}); | |
}); | |
}, r -> { | |
logger.info("complete"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment