I am using the client library for mb 3.4.1 java rabbit and cannot get the auto recovery mechanism.
Here's how I create a rabbit factory mk mix:
factory = new ConnectionFactory(); factory.setUsername(userName); factory.setPassword(password); factory.setVirtualHost(virtualHost); factory.setAutomaticRecoveryEnabled(true); factory.setNetworkRecoveryInterval(5); factory.setRequestedHeartbeat(3);
After posting the message, if I close the mq broker rabbit and return it again, I expect the recovery mechanism to start working and restore the connection to the βnormalβ state. But I get the following error:
com.rabbitmq.client.AlreadyClosedException: connection is already closed due to connection error; protocol method:
Am I missing something? The only way around this problem is to register the ShutDownListener and reinitialize the rabbit factory mq connection, connection and channels.
Also to answer
"chrislott"
comment, I see that system recovery is being restored to restore. I create an exchange using a temporary channel:
Channel channel = connection.createChannel(); channel.exchangeDeclare(exchangeName, exchangeType, durable); channel.close();
And I see the following exception when trying to restore the topology:
Caught an exception when recovering topology Caught an exception while recovering exchange testSuccessfulInitVirtualHost_Exchange: channel is already closed due to clean channel shutdown; protocol method:
The above exception is not visible unless I close the channel used to create the exchange.
source share