My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Vert.x and Blocking Code

Vert.x and Blocking Code

Jan Vladimir Mostert's photo
Jan Vladimir Mostert
·Oct 21, 2016

When using Vert.X on top of existing blocking code, you'll frequently run into plenty of errors and warnings in your logs as Vert.X is trying to warn you that you are blocking the event loop.

WARNING: Thread Thread[vert.x-eventloop-thread-1,5,main] has been blocked for 7221 ms, time limit is 2000 io.vertx.core.VertxException: Thread blocked

This article explores Vert.X approved solutions to run blocking code inside Thread Pools so that you can make use of Vert.X in the real world where you have to make use of many blocking services.

Alternatively, if you're using VertX Web, you can use their blocking handler which would allow you to call blocking methods.

this.get(path).blockingHandler { routingContext ->

or

this.post(path).blockingHandler { routingContext ->