Apache ActiveMQ Notes

Russell Bateman
April 2014
last update:


Configuration in .xml files...

If using XBean to parse the XML configuration: Some settings require...

<beans ...
  xsi:schemaLocation="
        http://activemq.apache.org/schema/core
        http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd
  ">

...in case of XML validation. If no validation is necessary, then there is no header. (This path is, of course, appended to xsi:schemaLocation in the case where there are other schemas listed.)


Sample plug-in configuration

This goes into the XML configuration. logMessageEvents limits the logfile content to the "minimum verbose" amount. Here we turn off connection-event logging.

    <plugins>
      <loggingBrokerPlugin logMessageEvents="true" logConnectionEvents="false" />
    </plugins>

Full configuration example

...from inside an XBean file. Some macro pronouns are filled in by the Maven build.

  <broker xmlns="http://activemq.apache.org/schema/core"
        brokerName="${project.artifactId}"
				dataDirectory="${homeDir}/data/${project.artifactId}"
				useJmx="true">

    <plugins>
      <simpleAuthenticationPlugin anonymousAccessAllowed="false">
        <users>
          <authenticationUser username="#adminUsername" password="#adminPassword" groups="admins" />
          <authenticationUser username="#adminROUsername" password="#adminROPassword" groups="adminsRO" />
        </users>
      </simpleAuthenticationPlugin>

      <authorizationPlugin>
        <map>
          <authorizationMap>
            <authorizationEntries>
              <!-- queue or topic name of ">" represents all queues or topics -->
              <authorizationEntry queue=">" read="admins,adminsRO" write="admins" admin="admins,adminsRO" />
              <authorizationEntry topic=">" read="admins,adminsRO" write="admins" admin="admins" />

              <authorizationEntry topic="ActiveMQ.Advisory.>" read="admins,adminsRO" write="admins,adminsRO" admin="admins,adminsRO"/>
            </authorizationEntries>
          </authorizationMap>
        </map>
      </authorizationPlugin>
    </plugins>

    <destinationInterceptors>
      <virtualDestinationInterceptor>
        <virtualDestinations>
          <virtualTopic name="VirtualTopic.CT.CHANGES" prefix="Consumer.*." selectorAware="true"/>
        </virtualDestinations>
      </virtualDestinationInterceptor>
    </destinationInterceptors>

    <plugins>
      <virtualSelectorCacheBrokerPlugin persistFile="selectorcache.data"/>
    </plugins>

    <!--
      The managementContext is used to configure how ActiveMQ is exposed in
      JMX. By default, ActiveMQ uses the MBean server that is started by
      the JVM. For more information, see:
        http://activemq.apache.org/jmx.html
    -->
    <managementContext>
      <managementContext createConnector="true"/>
    </managementContext>

    <!--
      Configure message persistence for the broker. The default persistence
      mechanism is the KahaDB store (identified by the kahaDB tag).
      For more information, see:
        http://activemq.apache.org/persistence.html
    -->
    <persistenceAdapter>
      <jdbcPersistenceAdapter dataDirectory="${activemq.data}" dataSource="#c3p0PostgreSQL" createTablesOnStartup="true" lockKeepAlivePeriod="5000">
        <locker>
          <lease-database-locker lockAcquireSleepInterval="10000"/>
        </locker>
      </jdbcPersistenceAdapter>
    </persistenceAdapter>

    <!--
      The systemUsage controls the maximum amount of space the broker will
      use before slowing down producers. For more information, see:
        http://activemq.apache.org/producer-flow-control.html
    -->
    <systemUsage>
      <systemUsage>
        <memoryUsage>
          <memoryUsage limit="2048 mb"/>
        </memoryUsage>
        <storeUsage>
          <storeUsage limit="75 gb"/>
        </storeUsage>
        <tempUsage>
          <tempUsage limit="1 gb"/>
        </tempUsage>
      </systemUsage>
    </systemUsage>

    <!--
      The transport connectors expose ActiveMQ over a given protocol to
      clients and other brokers. For more information, see:
        http://activemq.apache.org/configuring-transports.html
    -->
    <transportConnectors>
      <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
    </transportConnectors>

    <plugins>
      <loggingBrokerPlugin logMessageEvents="true" logConnectionEvents="false" />
    </plugins>
  </broker>