Search code examples
multithreadingkotlinrx-java2vert.xblocking

Vertx - Calling library which creates new thread


I am developing a RESTful API with Kotlin, Rx and Vert.x and I need to use a library which has a connection method where new threads are created.

I made some research in the code of the library and I saw that it can put threads to sleep, so I realize I need to call it with .rxExecuteBlocking() method, but my question is:

What is going to happen with new threads released by the library in Vertx? Taking into account the event loop pattern and so.

Thanks!


Solution

  • In general, you should use worker verticles to execute blocking code. You can read more about it here:

    https://vertx.io/docs/vertx-core/java/#worker_verticles

    Then use EventBus to communicate with worker verticles. Make sure you're using send() and reply() mechanism for that.