java - spring-rabbitmq 自动重试连接到代理

标签 java spring-boot spring-integration spring-amqp spring-rabbit

我已经阅读了这个文档片段:

RabbitMQ Automatic Connection/Topology recovery

Since the first version of Spring AMQP, the framework has provided its own connection and channel recovery in the event of a broker failure. Also, as discussed in Section 3.1.10, “Configuring the broker”, the RabbitAdmin will re-declare any infrastructure beans (queues etc) when the connection is re-established. It therefore does not rely on the Auto Recovery that is now provided by the amqp-client library. Spring AMQP now uses the 4.0.x version of amqp-client, which has auto recovery enabled by default. Spring AMQP can still use its own recovery mechanisms if you wish, disabling it in the client, (by setting the automaticRecoveryEnabled property on the underlying RabbitMQ connectionFactory to false). However, the framework is completely compatible with auto recovery being enabled. This means any consumers you create within your code (perhaps via RabbitTemplate.execute()) can be recovered automatically.

我不确定我是否理解正确。在我的 application.properties 中,我定义了端口和主机。在启动我的 spring-boot 应用程序期间,它成功建立了连接和所有必要的 bean 以与队列通信。

但是,如果在启动期间我的应用程序代理关闭并且它将在应用程序启动五分钟后启动,该怎么办? spring-rabbitmq 是否设法重新连接并定义所有 bean?

最佳答案

没错。 Spring AMQP 自动管理重新连接和恢复。

这个主题与 bean 定义无关。如果您谈论 Broker 实体声明,那么是的,它们实际上是在建立连接时处理的。

关于java - spring-rabbitmq 自动重试连接到代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42981299/

相关文章:

java - 输出未像使用 FileWriter 那样打印到文件

java - @StaticMetamodel 和 SingularAttribute<Obj,Obj> 是什么?

java - 有趣的内存值

spring-boot - 如何在Spring云配置服务器中使纯文本文件特定于应用程序?

spring-boot - 如何配置我的 NGINX 以在我的 Spring Boot 应用程序上允许 CSRF 保护

testing - 如何测试在 spring-integration 中使用 channel 的热文件夹?

spring - 在Spring集成中编写没有xml配置的sftp入站和出站适配器

java - 在阵列中进行完整性检查?

java - 避免代码重复 Spring Boot Controller

spring - Spring `@Configuration` 类的排序