Khanh Lâm
Khanh Lâm

Reputation: 57

Difference between standard verticle and worker verticle

I am confused about standard verticle and worker verticle in Vertx. And What are the use cases of them?

Upvotes: 0

Views: 3211

Answers (1)

Vert.x is an event-driven and non-blocking toolkit. When a “standard” verticle gets executed, its logic runs on an event loop thread. Whilst this thread runs the logic of that verticle, it cannot serve any other request, so this thread should not execute any blocking code.

But, sometimes, you do need to execute blocking code — doing a long computation, calling an external service synchronously, etc. — in which case, you need to make sure this doesn't happen on an event loop thread.

You have two ways to execute blocking code:

  • Use a worker verticle, which will execute code in its own thread pool, that can you can configure as needed;
  • Or use an executeBlocking block, which executes in a separate thread.

Upvotes: 6

Related Questions