问题描述
如何在Rabbitmq春天的CachingConnectionFactory bean上设置心跳属性?这是在云铸造环境中.因此,该应用程序将通过清单文件使用服务绑定,而我没有代理主机名.在我的SimpleMessageListenerContainer
bean中,我使用了CachingConnectionFactory bean,并且我猜它是由Spring自动装配的.
How should I set the heartbeat property on a CachingConnectionFactory bean in rabbitmq spring?This is in a cloud foundry environment. So the application will be using a service binding via manifest file and I don't have the broker host name.In my SimpleMessageListenerContainer
bean, I make use of the CachingConnectionFactory bean and I guess it's autowired by Spring.
我可以在那里做
@Bean
SimpleMessageListenerContainer container(CachingConnectionFactory connectionFactory,
MessageListenerAdapter listenerAdapter) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
connectionFactory.setRequestedHeartbeat(60);
container.setConnectionFactory(connectionFactory);
...
}
由于我没有为CachingconnectionFactory创建Bean,因此我没有分配该属性的位置,这是我看到的唯一位置.
since I am not creating a bean for CachingconnectionFactory, I don't have a place for assigning that property, this is the only place I see for it.
还有其他方法可以在ConnectionFactory的自动配置设置中分配此属性吗?谢谢
Is there any other way to assign this property on ConnectionFactory in auto-configured setting?thanks
推荐答案
请参见 Spring Boot属性文档.
spring.rabbitmq.requested-heartbeat= # Requested heartbeat timeout, in seconds; zero for none.
这篇关于在rabbitmq autoconfig connectionfactory bean上设置心跳属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!