ActiveMQ Broker Factory 找不到用于故障转移的工厂 class

ActiveMQ Broker Factory Could not find factory class for failover

我在尝试使用 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

这可能是路径错误吗?我不包括所需的罐子吗? url 格式不正确吗?我迷路了。

编辑:添加赏金

这不是类路径或 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