'RabbitMQPublisher sometimes fails to recover

I am using Vertx 4.2.1 with RabbitMQ client and I just noticed that sometimes when the rabbitMQ client loose connection and reconnect, the RabbitMQPublisher is not able to publish messages anymore. It means that my call to publisherClient.rxPublish(...) never completes and it does not throw any error.

My client settings are:

new RabbitMQOptions().setAutomaticRecoveryEnabled(true)
                    .setReconnectAttempts(0)
                    .setNetworkRecoveryInterval(1000L);

Are there some settings or something to prevent this situation ?

For now, I am trying to resolve the issue with the following workaround:

publisherClient.rxPublish(......)
                    .timeout(5, TimeUnit.SECONDS)
                    .doOnError(err -> {
                        if (err instanceof TimeoutException) {
                            LOG.warn("Publisher did not recover, so it will be restarted");
                            publisherClient.restart();
                        }
                    })
                    .retry(1L, err -> err instanceof TimeoutException)

As a small update on the issue: It seems to be reproducible, if we try to publish a message while a connection to RabbitMQ is down, we won't be able to publish any message later even if the connection is recovered and everything seems to be ok. The call to publisherClient.rxPublish(......) never completes

Thanks for help



Solution 1:[1]

How are you testing this? And how are you creating the exchange and queue that you are publishing to?

If the objects are not there when the server comes back then all messages will silently disappear. In order to create the objects you need to use the connection established callbacks, which are not currently accessible via the Rx wrapper.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yaytay