How to configure heartbeat for spring-rabbitmq

和自甴很熟 提交于 2019-12-14 03:48:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!