Tests for vertx bug that doesn't send instantaneously messages while processing handlers!
- vert-x3/vertx-hazelcast#43 - (clustured vertx)!
- eclipse-vertx/vert.x#1631 (non clustered vertx)!
It seems that vertx
in some cases doesn't send messages instantaneously.
That means while a vertx
is very busy/active there is no messages dispatched to eventBus until the vertx
becomes completely idle, that could be a big limitation if there is a need to send messages immediately.
To illustrate the issues, I created a simple ping pong example with junit tests.
- Ping sends several messages to pong;
- Pong emulates a 50ms processing time and reply back the message to ping.
- Ping, in some cases, doesn't receive immediately the message after pong has processed it.
The tests includes two workarounds (while the fix is not available) that solves the issue:
- using
WorkerExecutor
(available since vertx 3.3.x) - Vertx documentation - using java
ExecutorService
The issue happens when using vertx.executeBlocking
(only for non ordered) or when processing default code in a Multi-Thread Worker
.
v Test Type / Pong Verticle Type > | Standard | Worker | MT Worker |
---|---|---|---|
Direct code (No executeBlocking) | ✔️ | ✔️ | ✖️≥ 40 |
vertx.executeBlocking(ordered) | ✔️ | ✔️ | ✔️ |
vertx.executeBlocking(not ordered) | ✖️≥ 40 |
✖️≥ 40 |
✖️≥ 40 |
workerExecutor.executeBloking(ordered) | ✔️ | ✔️ | ✔️ |
workerExecutor.executeBloking(not ordered) | ✔️ | ✔️ | ✔️ |
javaExecutor.process(ordered) | ✔️ | ✔️ | ✔️ |
javaExecutor.process(not ordered) | ✔️ | ✔️ | ✔️ |
The issue happens when using vert.executeBlocking
in a worker verticle and when processing default code in a verticle (independently of the verticle type).
This issue could be connected with this issue: vert-x3/issues#75
v Test Type / Pong Verticle Type > | Standard | Worker | MT Worker |
---|---|---|---|
Direct code (No executeBlocking) | ✖️≥ 2 |
✖️≥ 2 |
✖️≥ 40 |
vertx.executeBlocking(ordered) | ✔️ | ✖️≥ 2 |
✖️≥ 2 |
vertx.executeBlocking(not ordered) | ✔️ | ✖️≥ 40 |
✖️≥ 40 |
workerExecutor.executeBloking(ordered) | ✔️ | ✔️ | ✔️ |
workerExecutor.executeBloking(not ordered) | ✔️ | ✔️ | ✔️ |
javaExecutor.process(ordered) | ✔️ | ✔️ | ✔️ |
javaExecutor.process(not ordered) | ✔️ | ✔️ | ✔️ |
Note: The -Dvertx.hazelcast.async-api=true
doesn't influence the result.
mvn clean package
mvn clean test
- Ubuntu 16.04 LTS
- Java 1.8.0_101-b13