I'm using a CachingConnectionFactory
and after a primary broker goes down it connects to the secondary. After restarting the primary broker I want to reconnect to it. Can this be done automatically?
This is what I've tried and it doesn't work:
factory.setRecoveryListener(new RecoveryListener() {
@Override
public void handleRecovery(final Recoverable recoverable) {
factory.resetConnection();
}
@Override
public void handleRecoveryStarted(final Recoverable recoverable) {
factory.resetConnection();
}
});
Can the factory be setup to take care of resetting the connection after the primary broker is back up?
Spring AMQP doesn't use auto recovery and, in any case, that is not called just because the original broker is back online.
You need some external mechanism to detect the other broker is back online, and call resetConnection()
from there.