javavert.xevent-busvertx-eventbus

Is there any scenario in which a Vert.x MessageConsumer can fail to unregister from the event bus?


public void unregisterConsumer(MessageConsumer<Object> mc) {
    mc.unregister(result -> {
        if(result.succeeded())
            return;
        else
            //uh oh
    });
    
}

In the event of a failed AsyncResult, would it be unwise to just call unregisterConsumer again, perhaps with a vertx.setTimer(5000, id -> unregisterConsumer(mc));?


Solution

  • If Vert.x is not clustered, the chances you get a failure are negligible (it would only happen in case of a bug).

    If Vert.x is clustered, this may happen if the underlying cluster manager fails to remove the subscription (e.g. if network communication is lost).

    As for retrying, it can be a good idea if your application registers consumers dynamically. Otherwise you can ignore the failure and let the process die. The cluster manager will clean-up the subscriptions, eventually.