Verticle consumer inconsistency

22 views
Skip to first unread message

oxy...@gmail.com

unread,
Jun 26, 2024, 11:45:14 AM (6 days ago) Jun 26
to vert.x
Hi all,

I have been chasing a race condition for the last 3 days, this is driving me crazy at this point, I have this caching system where I create a Verticle per address with a consumer, similar to an actor system, here is the screenshot of the relevant code, will explain after it:

I have this latch:
CountingLatch startedStoppedLatch = new CountingLatch(2);

I have this completion handler at the consumer:
consumer.completionHandler(event -> startedStoppedLatch.decrement());

and I have this onComplete at when I deploy:
public void deploy(DeploymentOptions deploymentOptions)
{
  try {
    VertxService.vertx().deployVerticle(this, deploymentOptions).onComplete(event -> startedStoppedLatch.decrement());
    startedStoppedLatch.await();
  } catch (Exception e) {
    log.error("Error deploying processor verticle {}", consumer.address(), e);
  }
}

It doesn't matter what I tried, it seems that sending or publishing just after creating the Verticle will have a tiny chance of not delivering the message to the consumer, what am I doing wrong?

Guido.

oxy...@gmail.com

unread,
Jun 26, 2024, 11:51:11 AM (6 days ago) Jun 26
to vert.x
More context: Java 11, Vert.x 4.5.8, localConsumer, publishing/sending local only, so my Vert.x instance is not clustered.
Reply all
Reply to author
Forward
0 new messages