问题
How can I configure spring-rabbitmq connection-factory
<rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host}" port="${rabbitmq.port:5672}"
username="guest" password="guest"/>
With a requested heartbeat ?
回答1:
You can provide the underlying connection factory as a bean, properties set on the rabbit:connection-factory will be overridden.
<rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host}" port="${rabbitmq.port:5672}"
username="guest" password="guest" connection-factory="rcf" />
<bean id="rcf" class="com.rabbitmq.client.ConnectionFactory">
<property name="host" value="${rabbitmq.host}"/>
<property name="requestedHeartbeat" value="10" />
</bean>
回答2:
You should use requestedHeartbeat
property for connectionfacory bean
<bean id="rabbitconnectionFactory" class="com.rabbitmq.client.ConnectionFactory">
<property name="host" value="localhost"/>
<property name="requestedHeartbeat" value="100" />
</bean>
来源:https://stackoverflow.com/questions/11559369/how-to-configure-heartbeat-for-spring-rabbitmq