2

我正在创建一个嵌入式 activemq 实例,以便通过 JMX 测试创建/删除主题。代码看起来有点像下面。broker.connectorPort 是我尝试设置 JMX 端口,但它不起作用。

String connectString="vm://localhost?broker.persistence=false&broker.useJmx=true&broker.connectorPort=2011"

ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();

activeMQConnectionFactory.setBrokerURL(connectString);

ActiveMQConnection activeMQConnection = (ActiveMQConnection) activeMQConnectionFactory.createConnection();
activeMQConnection.start();

使用 activemq.xml 配置时,以下 xml 有效。我不确定如何将其翻译为 brokerURL。

<managementContext>
        <managementContext connectorPort="2011" createConnector="true"/>
</managementContext>
4

1 回答 1

2

通过手动创建代理解决..

    BrokerService broker = new BrokerService();
    broker.setUseJmx(true);
    broker.getManagementContext().setConnectorPort(9999);
    broker.start();
于 2011-06-29T19:20:02.140 回答