2011-06-29 31 views
2

我正在創建一個嵌入式activemq實例,以便通過JMX測試創建/刪除主題。代碼看起來有點像以下內容。 broker.connectorPort是我嘗試設置JMX端口但它不起作用。如何爲嵌入式activemq實例指定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> 

回答

2

通過手動創建代理解決..

BrokerService broker = new BrokerService(); 
    broker.setUseJmx(true); 
    broker.getManagementContext().setConnectorPort(9999); 
    broker.start();