Adding an ActiveMQ broker in ServiceMix

Out of the box ServiceMix comes with a preconfigured ActiveMQ broker, which is started when you start ServiceMix.

karaf@root> osgi:list | grep mq
[  43] [Active     ] [Created     ] [       ] [   60] activemq-core (5.4.1.fuse-00-00)
[  45] [Active     ] [            ] [       ] [   60] activemq-console (5.4.1.fuse-00-00)
[  46] [Active     ] [            ] [       ] [   60] activemq-ra (5.4.1.fuse-00-00)
[  47] [Active     ] [            ] [       ] [   60] activemq-pool (5.4.1.fuse-00-00)
[  48] [Active     ] [Created     ] [       ] [   60] activemq-karaf (5.4.1.fuse-00-00)
[  53] [Resolved   ] [            ] [       ] [   60] activemq-blueprint (5.4.1.fuse-00-00)
[  54] [Active     ] [Created     ] [       ] [   60] activemq-broker.xml (0.0.0)

Bundle 54 is the default broker. You can configure it by changing the file SERVICEMIX_HOME/etc/activemq-broker.xml

You can add an extra broker by using the command activemq:create-broker in the ServiceMix shell:

karaf@root> activemq:create-broker --name=test
Creating file: @|green C:javaapache-servicemix-4.3.0-fuse-02-00deploytest-broker.xml|

Default ActiveMQ Broker (test) configuration file created at: C:javaapache-servicemix-4.3.0-fuse-02-00deploytest-broker.xml
Please review the configuration and modify to suite your needs.

This command creates a configuration file for your new browser, for this example it’s called SERVICEMIX_HOME/deploy/test-broker.xml

You need to change it because it’s using the same ports as the default broker. Look for the following lines in the configuration file and change the ports to something unused.

...
        <!-- The transport connectors ActiveMQ will listen to -->
        <transportConnectors>
            <transportConnector name="openwire" uri="tcp://localhost:61816"/>
            <transportConnector name="stomp" uri="stomp://localhost:61813"/>
        </transportConnectors>
    </broker>
    <bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:61816" />
    </bean>
...    

Next, you need to install the activemq-spring feature to avoid as the broker configuration file generated uses spring, instead of osgi blueprint as the default does.

karaf@root> features:install activemq-spring

If you list the ActiveMQ brokers, you’ll see that you have two:

karaf@root> activemq:list --jmxlocal
BrokerName = test
BrokerName = default
blog comments powered by Disqus