matrik
matrik

Reputation: 21

Execution of event handlers in vertx

If I have the following code:

for(int i = 0; i < 10; i++)
{
    vertx.eventBus().send("some-address", some-handler);
}

Are all the calls to the some-handler in this loop executed parallel or sequential? If sequential, what would be the right approach in order to get parallel execution?

Regards

Upvotes: 1

Views: 878

Answers (1)

user4695271
user4695271

Reputation:

The execution is "sequential" since sending a message will result in only one "handler" registered — at the address receiving the message. Theoretically, if you want a parallel execution, you must deploy two (or more) verticles registered for that particular "handler" and start publishing messages. Keep in mind that Vert.x does not have concurrency for a single verticle, which is the main point of the platform anyway.

Additionally, have a look at this link. That's the best (and concise) explanation I've seen so far for Concurrent and Parallel programming; will definitely give you a clue of what is what, although the jargon varies from language to language.

Upvotes: 2

Related Questions