尝试使用BrokerFactory创建ActiveMQ代理时出现此错误:
java.io.IOException: Could not load failover factory:java.io.IOException: Could not find factory class for resource: META-INF/services/org/apache/activemq/broker/failover
at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
at org.apache.activemq.broker.BrokerFactory.createBrokerFactoryHandler(BrokerFactory.java:43)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:70)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)
at ...
Caused by: java.io.IOException: Could not find factory class for resource: META-INF/services/org/apache/activemq/broker/failover
at org.apache.activemq.util.FactoryFinder$StandaloneObjectFactory.loadProperties(FactoryFinder.java:96)
at org.apache.activemq.util.FactoryFinder$StandaloneObjectFactory.create(FactoryFinder.java:58)
at org.apache.activemq.util.FactoryFinder.newInstance(FactoryFinder.java:146)
at org.apache.activemq.broker.BrokerFactory.createBrokerFactoryHandler(BrokerFactory.java:41)
... 5 more
似乎路径错误或类似的东西,我只是无法找出根本原因。
这是导致它的代码:
URI brokerUri = new URI(bean.getBrokerConfigUrl());
broker = BrokerFactory.createBroker(brokerUri);
这是我打电话的网址:
failover:(tcp://internalUrl.net:port#,tcp://internalUrl.net:port#)?randomize=false&timeout=30000&jms.redeliveryPolicy.maximumRedeliveries=-1&jms.prefetchPolicy.all=0
这可能是路径错误吗?我不包括一个必需的罐子吗?网址格式不正确吗?我迷失了。
编辑:添加了赏金
答案 0 :(得分:3)
这不是类路径或jar问题。根据活动的MQ文档,BrokerFactory仅支持xbean,代理或属性的URI,并且不支持故障转移URI。
以下两个文档应该为您提供有关设置和配置代理工厂的更多信息。
http://activemq.apache.org/broker-configuration-uri.html
http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html