LibraryToggle FramesPrintFeedback

Configuring Credentials for Broker Components


Once authentication is enabled in the broker, every application component that opens a connection to the broker must be configured with credentials. This includes some standard broker components, which are normally configured using Spring XML. To enable you to set credentials on these components, the XML schemas for these components have been extended as described in this section.

Default credentials for broker components

For convenience, you can configure default credentials for the broker components by setting the activemq.username property and the activemq.password property in the conf/ file. By default, this file has the following contents:


Command agent

You can configure the command agent with credentials by setting the username attribute and the password attribute on the commandAgent element in the broker configuration file. By default, the command agent is configured to pick up its credentials from the activemq.username property and the activemq.password property as shown in the following example:

  <commandAgent xmlns=""
                password="${activemq.password}" />


Apache Camel

The default broker configuration file contains an example of a Apache Camel route that is integrated with the broker. This sample route is defined as follows:

  <camelContext id="camel" xmlns="">
      <from uri="activemq:example.A"/>
      <to uri="activemq:example.B"/>

The preceding route integrates with the broker using endpoint URIs that have the component prefix, activemq:. For example, the URI, activemq:example.A, represents a queue named example.A and the endpoint URI, activemq:example.B, represents a queue named example.B.

The integration with the broker is implemented by the Camel component with bean ID equal to activemq. When the broker has authentication enabled, it is necessary to configure this component with a userName property and a password property, as follows:

  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
    <property name="connectionFactory">
      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?create=false&amp;waitForStart=10000" />
        <property name="userName" value="${activemq.username}"/>
        <property name="password" value="${activemq.password}"/>
Comments powered by Disqus