Schlagwort-Archive: ServiceMix

Securing the embedded ActiveMQ in ServiceMix

As soon as you investigate possibilities to let other software connect to the ActiveMQ that comes packaged with ServiceMix you might want to secure those connections. An important step is to authenticate and authorize the clients. This post is based on ServiceMix 4.4.2 and especially highlights the configuration that is required on the ServiceMix side to be able to connect flawlessly to ActiveMQ as it does without authentication.

The first step is to configure the ActiveMQ broker with authentication in $SMX_HOME/etc/activemq-broker.xml. Details can be found on the ActiveMQ homepage.

<blueprint xmlns=""
 <broker xmlns="" brokerName="default" dataDirectory="${}/activemq/default" useShutdownHook="false">
     <authenticationUser username="user1" password="mypw" groups="group1" />
     <authenticationUser username="user2" password="mypw" groups="group2" />
       <!-- Basis permissions applicable to all queues and topics -->
       <authorizationEntry queue=">" read="group1" write="group1" admin="group1" />
       <authorizationEntry topic=">" read="group1" write="group1" admin="group1" />

       <!-- Especially important - everyone needs access here, otherwise clients cannot connect -->
       <authorizationEntry topic="ActiveMQ.Advisory.>" read="group1,group2" write="group1,group2" admin="group1,group2"/>

       <!-- Special access rule for queue "myqueue" -->
       <authorizationEntry queue="myqueue" read="group1,group2" write="group1,group2" admin="group1,group2" />
 <!-- This configures a connection factory that can be used from your camel rules -->
 <bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
  <property name="brokerURL" value="vm://default?create=false&amp;waitForStart=10000" />
  <property name="userName" value="user1" />
  <property name="password" value="mypw" />

But now – if you’re using the ActiveMQ webconsole, you will notice it can’t browse queues anymore. To reenable it to do this, just add the following to $SMX_HOME/etc/


The webconsole will use this data to connect to ActiveMQ. To enable all functionality I would recommend to create a „servicemix“ user with all privileges that you use for the webconsole as well as the default connection pool for your Camel routes.

Last but not least you can reference the default connection pool in your camel routes like this (using the Spring bean syntax). This avoids having to configure a separate connection pool for each route (along with username and password).

<beans xmlns=""
 <osgi:reference id="pooledConnectionFactory" interface="javax.jms.ConnectionFactory" />
 <camelContext xmlns="">

That’s it. After you restart ServiceMix it will have a (very basically) secured ActiveMQ. For a more sophisticated security configuration of ActiveMQ, I once again point you to the ActiveMQ homepage.