I noticed from AMQP-62 open bug there was not a direct way of setting the heartbeat, but it mentioned in the comments that it should be easy to reference a raw rabbit ConnectionFactory to accomplish this.
I tried the following:
The application will not start up - it just hangs. In fact the unit tests will not pass, and also hangs - no messages.Code:<rabbit:connection-factory id="rabbitConnectionFactory" host="${rabbitmq.host}" username="${rabbitmq.username}" port="${rabbitmq.port}" password="${rabbitmq.password}" virtual-host="/" connection-factory="rabbitConn"/> <bean id="rabbitConn" class="com.rabbitmq.client.ConnectionFactory" p:requestedHeartbeat="10" p:host="${rabbitmq.host}" p:username="${rabbitmq.username}" p:port="${rabbitmq.port}" p:password="${rabbitmq.password}" p:virtualHost="/" p:connectionTimeout="1000"/>
I have tried many variations on this - none work as long as I leave the "rabbitConn" bean in the configuration.
If I remove (i.e. comment) the rabbitConn bean (and remove the associated "connection-factory" reference in the spring-amqp element), it all works, but now it does not have the heartbeat set.
I have tried leaving the username, password, etc in the raw bean, or just in the spring-amqp bean, or both, nothing works. Any hints on how I reference a rabbitmq Connection in a way I can set the heartbeat (and have it work)?
As a side note, the reason for the heartbeat is in our production system IT uses a load balancer setup for the rabbit. We have found, for our erlang applications, we need to have a heartbeat running or if their is a significant pause in messages on some queue, the load balancer will mess with the connection and rabbit does not handle the interruption in a way the clients can subsequently send or receive messages. I am having the same symptom on the production system that the erlang applications had until they set the heartbeat. It does not occur on setups that does not have the load balancer.
This is running on Spring 3.1, Spring-Integration 2.1, RabbitMQ 2.6.0, Spring-amqp 1.0.0 client (with amqp 2.5.1 client jar from dependency)


Reply With Quote
