Tom
Tom

Reputation: 2444

How do I specify the JMX port for an embedded activemq instance?

I am creating an embedded activemq instance in order to test creating/deleting topics via JMX. The code looks a bit like the following. broker.connectorPort was my attempt to set the JMX port but it does not work.

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();

When configuring using activemq.xml the following xml works. Im not sure how to translate this to brokerURL.

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

Upvotes: 2

Views: 2624

Answers (1)

Tom
Tom

Reputation: 2444

Solved by creating broker manually..

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

Upvotes: 2

Related Questions