如何配置spring-rabbitmq connection-factory
<rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host}" port="${rabbitmq.port:5672}"
username="guest" password="guest"/>
请求心跳?
答案 0 :(得分:8)
您可以将底层连接工厂提供为bean,在Rabbit上设置属性:将覆盖connection-factory。
<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>
答案 1 :(得分:0)
您应该对connectionfacory bean使用requestedHeartbeat
属性
<bean id="rabbitconnectionFactory" class="com.rabbitmq.client.ConnectionFactory">
<property name="host" value="localhost"/>
<property name="requestedHeartbeat" value="100" />
</bean>