尝试使用 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);
这是我调用的 url:
failover:(tcp://internalUrl.net:port#,tcp://internalUrl.net:port#)?randomize=false&timeout=30000&jms.redeliveryPolicy.maximumRedeliveries=-1&jms.prefetchPolicy.all=0
这可能是路径错误吗?我不包括所需的 jar 吗? url 格式不正确?我在这里迷路了。
编辑:增加赏金
最佳答案
这不是类路径或 jar 问题。根据 Activity 的 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
关于java - ActiveMQ Broker Factory 找不到用于故障转移的工厂类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31861240/