LibraryToggle FramesPrintFeedback

Configuring Credentials for Broker Components

Overview

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/credentials.properties file. By default, this file has the following contents:

activemq.username=system
activemq.password=manager

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:

<beans>
  ...
  <commandAgent xmlns="http://activemq.apache.org/schema/core"
                brokerUrl="vm://localhost"
                username="${activemq.username}"
                password="${activemq.password}" />

  ...
</beans>

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:

<beans>
  ...
  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
    <package>org.foo.bar</package>
    <route>
      <from uri="activemq:example.A"/>
      <to uri="activemq:example.B"/>
    </route>
  </camelContext>
  ...
</beans>

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:

<beans>
  ...
  <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}"/>
      </bean>
    </property>
  </bean>
  ...
</beans>
Comments powered by Disqus