如何为spring-rabbitmq配置心跳

时间:2012-07-19 10:57:47

标签: rabbitmq spring-rabbit

如何配置spring-rabbitmq connection-factory

<rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host}" port="${rabbitmq.port:5672}"
    username="guest" password="guest"/>

请求心跳?

2 个答案:

答案 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>