问题
@Bean
public StatefulRetryOperationsInterceptor interceptor() {
return RetryInterceptorBuilder.stateful()
.maxAttempts(5)
.backOffOptions(1000, 2.0, 10000)
.build();
}
Can we use this bean for spring-rabbitmq automatic recovery because spring rabbit does not supports
factory.setAutomaticRecoveryEnabled(true);
factory.setNetworkRecoveryInterval(10000);
回答1:
It's not clear what your question is.
The retry @Bean is for retrying when your application listener fails to process a message.
The recovery settings are for recovering connections/channels when the connection to the broker is lost.
Spring AMQP has its own re-connection (recoveryInterval
on the listener container) so it's not really needed to set the rabbit client options. When using Spring AMQP < 1.4.0, you must not set these options.
If you are using Spring AMQP 1.4.0 or greater, you can set those on the underlying connection factory, as described in the documentation but it's not really necessary because Spring AMQP will reconnect for you.
来源:https://stackoverflow.com/questions/27147892/spring-rabbitmq-automatic-recovery-enable