简体   繁体   中英

Rabbit MQ heartbeat configuration not reflected using java

We are trying to set the requestedHeartbeat value using

 <rabbit:connection-factory id="connectionFactory" host="#{rabbitmq.hostname}" username="#{rabbitmq.username}" password="#{rabbitmq.password}" virtual-host="#{rabbitmq.virtualhost}" publisher-confirms="false" publisher-returns="false" requested-heartbeat="120" port="#{rabbitmq.port}"/>

we create a consumer object using

 AbstractApplicationContext context = new ClassPathXmlApplicationContext("classpath:/consumer_context.xml"); SimpleMessageListenerContainer container = context.getBean(SimpleMessageListenerContainer.class);

container.connectionFactory.rabbitConnectionFactory has the value as 120

But when we check the connections heartbeat in RabbitMQ UI, it shows the value as 60.

Could any one please suggest what am i missing?

I tried even with spring.rabbitmq.requested-heartbeat in application.properties as well. It did not work.

We are using spring-rabbit 2.1.8 RabbitMQ 3.7.15 Erlang 22.0.4

RabbitMQ config also has a heartbeat value, so you might want to change that too.

https://www.rabbitmq.com/configure.html Value representing the heartbeat timeout suggested by the server during connection parameter negotiation. If set to 0 on both ends, heartbeats are disabled (this is not recommended). See the Heartbeats guide for details. Default:

heartbeat = 60

https://www.rabbitmq.com/heartbeats.html#using-heartbeats-in-java Note that in case RabbitMQ server has a non-zero heartbeat timeout configured (which is the default in versions starting with 3.6.x), the client can only lower the value but not increase it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM