@Test
public void test(@NotNull TestContext context) throws InterruptedException {
final Async async = context.async(2);
getVertx().deployVerticle(new Vert1(async));
Thread.sleep(1000);
getVertx().eventBus().send("test", "testmsg");
getVertx().eventBus().send("test", "testmsg");
}
public static final class Vert1 extends AbstractVerticle {
private final @NotNull Logger logger = LoggerFactory.getLogger(this.getClass());
final @NotNull Async async;
public Vert1(@NotNull Async async) {
this.async = async;
}
@Override
public void start() {
vertx.eventBus().consumer("test", r -> {
vertx.sharedData().getLockWithTimeout("lock1", 100000, res -> {
if (res.succeeded()) {
logger.info("Lock11 catched");
sleep();
final Lock lock1 = res.result();
vertx.sharedData().getLockWithTimeout("lock2", 100000, res2 -> {
if (res2.succeeded()) {
logger.info("Lock21 catched");
res2.result().release();
lock1.release();
async.countDown();
} else {
logger.info("Lock21 catch failed");
lock1.release();
}
});
} else {
logger.info("Lock11 catch failed");
}
});
}
);
}
public static void sleep() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Unfortunately, this problem still actual without any sleep() call in event loop. |
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9fb84c3e-6081-4e49-bbe1-47ad979b39ba%40googlegroups.com.