为Grails使用Jms插件并为ActiveMQ添加依赖项工作非常完美。没问题。
现在我想去beyong并执行一些自定义和精细调整以使ActiveMQ按照我的需要运行,所以我需要配置代理实例。
e.g。我想使用JDBC存储。
如何使用grails和vm嵌入式代理进行此操作?
我实际上已经遵循了JMS grails插件的参考文档...我添加了jms插件和activemq依赖项并将其放在资源上:
jmsConnectionFactory(SingleConnectionFactory) {
targetConnectionFactory = { ActiveMQConnectionFactory cf ->
//brokerURL = 'vm://localhost'
brokerURL = 'tcp://localhost:61616?jms.useAsyncSend=true'
}
}
正如我所说,这很好......但我需要在这里进行更多调整,所以我试图在资源中添加这个,所以我可以访问代理进行微调:
/* Establish the broker */
amq.broker(useJmx: false, persistent: true) {
amq.transportConnectors() {
amq.transportConnector(uri: "tcp://localhost:61616")
}
}
amqConnectionFactory(ActiveMQConnectionFactory) {
brokerURL = "vm://localhost"
}
jmsConnectionFactory(SingleConnectionFactory) {
targetConnectionFactory = ref(amqConnectionFactory)
}
但我开始遇到依赖性问题,如:
2015-03-18 13:44:14 - spring.RuntimeSpringConfigUtilities [RuntimeConfiguration] Unable to load beans from resources.groovy
org.springframework.beans.FatalBeanException: NamespaceHandler class [org.apache.xbean.spring.context.v2.XBeanNamespaceHandler] for namespace [http://activemq.apache.org/schema/core] not found; nested exception is java.lang.ClassNotFoundException: org.apache.xbean.spring.context.v2.XBeanNamespaceHandler
所以我开始添加依赖项:
compile 'org.apache.activemq:activemq-spring:5.7.0'
compile 'org.springframework:spring-beans:4.1.1.RELEASE'
compile 'org.apache.xbean:xbean-spring:4.1'
但仍有问题:
java.lang.NoClassDefFoundError: org/springframework/core/OrderComparator$OrderSourceProvider
在这一点上,我感觉我做错了,因为我看到了太多的复杂性。
有最好的方法吗?
答案 0 :(得分:4)
为了能够配置ActiveMQ,您需要:
Depedencies:
compile 'org.apache.activemq:activemq-core:5.7.0'
compile 'org.apache.activemq:activemq-spring:5.7.0'
compile 'org.springframework:spring-beans:4.0.6.RELEASE'
compile 'org.apache.xbean:xbean-spring:4.1'
Resources.groovy:
xmlns amq:"http://activemq.apache.org/schema/core"
...
/* Establish the broker */
amq.broker(useJmx: false, persistent: true) {
amq.transportConnectors() {
amq.transportConnector(uri: "tcp://localhost:61616")
}
//HERE YOU CAN CONFIGURE BROKER
}
amqConnectionFactory(ActiveMQConnectionFactory) {
brokerURL = "vm://localhost"
}
jmsConnectionFactory(SingleConnectionFactory) {
targetConnectionFactory = ref(amqConnectionFactory)
}