在 grails 中运行时更改 ActiveMQConnectionFactory BrokerURL
我在resource.groovy中定义了一个bean,就像
beans = {
jmsConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) {bean ->
connectionFactory = {org.apache.activemq.ActiveMQConnectionFactory cf ->
brokerURL = brokerDestination
}
}
}
现在,有没有办法在运行时动态更改brokerURL,从而重新启动activemq连接?
I've got a bean defined in resource.groovy like
beans = {
jmsConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) {bean ->
connectionFactory = {org.apache.activemq.ActiveMQConnectionFactory cf ->
brokerURL = brokerDestination
}
}
}
Now, is there a way to dynamically change the brokerURL at runtime and therefore also restart the activemq connection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个更简单的解决方案是为每个代理和相应的 bean 目标定义多个连接工厂。然后,您可以根据您的要求有条件地在代码中交换目标 - 一旦 bean 初始化,就没有一种简单的方法可以返回并修改 bean 定义。
An easier solution will be to define multiple connection factories for each of your brokers and corresponding bean destinations. You can then swap out the destinations conditionally in your code based on your requirement - there would not be a easy way to go back and modify the bean definitions once the beans have been initialized.