spring rabbitmq automatic recovery enable

本秂侑毒 提交于 2019-12-11 18:34:41

问题


@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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!