Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vert.x Worker Thread Blocking

Tags:

worker

vert.x

I have one vert.x Standard Verticle Basically,it parses HttpRequest and prepare JsonObject then I am sending JSONObject through eventbus. In Another Worker verticle that event get consumed and it will kick off execution(includes call to Penthao Data Integration Java API) it is blocking API.It took around 30 minutes to complete execution of ".kjb" file. But vert.x is continuously warning about Worker Thread Block so my question is what would be best practice in vert.x to tackle this scenario. Any help would be highly appreciated.

like image 507
Aniket Kulkarni Avatar asked Jul 10 '26 15:07

Aniket Kulkarni


1 Answers

According to vertx doc all blocking operations need to perform in code

vertx.executeBlocking(future -> {
  // Call some blocking API that takes a significant amount of time to return
  String result = someAPI.blockingMethod("hello");
  future.complete(result);
}, res -> {
  System.out.println("The result is: " + res.result());
});

So it's the best practice for all blocking tasks.

like image 159
Eugene Kirin Avatar answered Jul 13 '26 15:07

Eugene Kirin