Current Release

This documentation covers the current version of Fedora. Looking for another version? See all documentation.

  1. Download the latest ActiveMQ 5 Linux .tar.gz from https://activemq.apache.org/components/classic/download

  2. Unpack the file and move it under /opt (or where ever you like, just remember this directory)

  3. Create a symlink from the unpacked directory to /opt/activemq (optional, makes it easier to handle updates later)

  4. Create an activemq user:
    sudo adduser --system --no-create-home activemq

  5. Change ownership:
    sudo chown -R activemq:activemq /opt/activemq/

  6. Set up the unit file in /usr/lib/systemd/system/activemq.service

    [Unit]
    Description=Apache ActiveMQ
    After=network-online.target


    [Service]
    Type=forking
    WorkingDirectory=/opt/activemq/bin
    ExecStart=/opt/activemq/bin/activemq start
    ExecStop=/opt/activemq/bin/activemq stop
    Restart=on-abort
    User=activemq
    Group=activemq

    [Install]
    WantedBy=multi-user.target

  7. Choice! You can disable the connectors for the internal Fedora ActiveMQ instance and have it ONLY forward messages, or you can choose to have both ActiveMQ instances available.

  8. Disable the internal ActiveMQ connectors

    1. Edit your Fedora properties file (i.e. /opt/fedora/fcrepo.properties) and add some properties to customize the configuration and file location for the internal Fedora ActiveMQ:

      fcrepo.activemq.configuration=file:///opt/fedora/config/activemq.xml
      fcrepo.activemq.directory=/opt/fedora/queue
    2. Create /opt/fedora/config/activemq.xml (this is the default Fedora ActiveMQ configuration with a fedora_bridge network connector to forward messages to your external ActiveMQ)

      Note the networkConnector element, the username/password is needed if you have enabled authentication on the external ActiveMQ and the uri points to the external ActiveMQ hostname and OpenWire port

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      
      xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
      <context:property-placeholder/>
          <bean id="activeMqDirectory" class="java.lang.String">
              <constructor-arg value="#{fedoraPropsConfig.activeMqDirectory}"/>
          </bean>
          <!--
              The <broker> element is used to configure the ActiveMQ broker.
          -->
          <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost">
              <networkConnectors>
                  <networkConnector name="fedora_bridge" username="fedora_user" password="<redacted>" dynamicOnly="true" uri="static:(tcp://localhost:61616)">
                      <dynamicallyIncludedDestinations>
                          <topic physicalName="fedora"/>
                          <queue physicalName="fedora"/>
                     </dynamicallyIncludedDestinations>
                 </networkConnector>
              </networkConnectors>
          <!--
              For better performances use VM cursor and small memory limit.
              For more information, see:
                  http://activemq.apache.org/message-cursors.html
              Also, if your producer is "hanging", it's probably due to producer flow control.
              For more information, see:
                  http://activemq.apache.org/producer-flow-control.html
           -->
              <destinationPolicy>
                  <policyMap>
                      <policyEntries>
                          <policyEntry topic=">" producerFlowControl="true">
                          <!-- The constantPendingMessageLimitStrategy is used to prevent
                                 slow topic consumers to block producers and affect other consumers
                                 by limiting the number of messages that are retained
      
                                 For more information, see:
                                 http://activemq.apache.org/slow-consumer-handling.html
                           -->
                              <pendingMessageLimitStrategy>
                                  <constantPendingMessageLimitStrategy limit="1000"/>
                              </pendingMessageLimitStrategy>
                         </policyEntry>
                         <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb">
                         <!-- Use VM cursor for better latency
                                 For more information, see:
                                 http://activemq.apache.org/message-cursors.html
                             <pendingQueuePolicy>
                                 <vmQueueCursor/>
                             </pendingQueuePolicy>
                          -->
                        </policyEntry>
                    </policyEntries>
                </policyMap>
            </destinationPolicy>
            <!--
             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="false"/>
            </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>
                <kahaDB directory="#activeMqDirectory"/>
            </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
             If using ActiveMQ embedded - the following limits could safely be used:
            -->
           <systemUsage>
                <systemUsage>
                     <memoryUsage>
                          <memoryUsage limit="20 mb"/>
                     </memoryUsage>
                     <storeUsage>
                          <storeUsage limit="1 gb"/>
                     </storeUsage>
                     <tempUsage>
                          <tempUsage limit="100 mb"/>
                     </tempUsage>
                </systemUsage>
            </systemUsage>
      
            <shutdownHooks>
                 <bean xmlns="http://www.springframework.org/schema/beans"
                     class="org.apache.activemq.hooks.SpringContextHook"/>
            </shutdownHooks>
        </broker>
         <!--
           Enable web consoles, REST and Ajax APIs and demos
           Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
           <import resource="jetty.xml"/>
          -->
      </beans>
  9. Keep both ActiveMQ instances available

    1. Edit /opt/activemq/conf/activemq.xml and change port numbers in the transportConnectors section (to avoid conflicts with Fedora’s built-in ActiveMQ):

      1. 61616 -> 41616

      2. 61613 -> 41613

    2. Start and enable the service:
      sudo systemctl enable activemq
      sudo systemctl start activemq

    3. Edit your Fedora properties file (i.e. /opt/fedora/fcrepo.properties) and add some properties to customize the configuration and file location for the internal Fedora ActiveMQ:
      fcrepo.activemq.configuration=file:///opt/fedora/config/activemq.xml
      fcrepo.activemq.directory=/opt/fedora/queue

    4. Create /opt/fedora/config/activemq.xml (this is the default Fedora ActiveMQ configuration with a fedora_bridge network connector added to forward messages to port 41616)

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
      <context:property-placeholder/>
          <bean id="activeMqDirectory" class="java.lang.String">
              <constructor-arg value="#{fedoraPropsConfig.activeMqDirectory}"/>
          </bean>
          <!--
              The <broker> element is used to configure the ActiveMQ broker.
          -->
          <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost">
              <networkConnectors>
                  <networkConnector name="fedora_bridge" dynamicOnly="true" uri="static:(tcp://localhost:41616)">
                      <dynamicallyIncludedDestinations>
                          <topic physicalName="fedora"/>
                          <queue physicalName="fedora"/>
                     </dynamicallyIncludedDestinations>
                 </networkConnector>
              </networkConnectors>
          <!--
              For better performances use VM cursor and small memory limit.
              For more information, see:
                  http://activemq.apache.org/message-cursors.html
              Also, if your producer is "hanging", it's probably due to producer flow control.
              For more information, see:
                  http://activemq.apache.org/producer-flow-control.html
           -->
              <destinationPolicy>
                  <policyMap>
                      <policyEntries>
                          <policyEntry topic=">" producerFlowControl="true">
                          <!-- The constantPendingMessageLimitStrategy is used to prevent
                                 slow topic consumers to block producers and affect other consumers
                                 by limiting the number of messages that are retained

                                 For more information, see:
                                 http://activemq.apache.org/slow-consumer-handling.html
                           -->
                              <pendingMessageLimitStrategy>
                                  <constantPendingMessageLimitStrategy limit="1000"/>
                              </pendingMessageLimitStrategy>
                         </policyEntry>
                         <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb">
                         <!-- Use VM cursor for better latency
                                 For more information, see:
                                 http://activemq.apache.org/message-cursors.html
                             <pendingQueuePolicy>
                                 <vmQueueCursor/>
                             </pendingQueuePolicy>
                          -->
                        </policyEntry>
                    </policyEntries>
                </policyMap>
            </destinationPolicy>
            <!--
             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="false"/>
            </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>
                <kahaDB directory="#activeMqDirectory"/>
            </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
             If using ActiveMQ embedded - the following limits could safely be used:
            -->
           <systemUsage>
                <systemUsage>
                     <memoryUsage>
                          <memoryUsage limit="20 mb"/>
                     </memoryUsage>
                     <storeUsage>
                          <storeUsage limit="1 gb"/>
                     </storeUsage>
                     <tempUsage>
                          <tempUsage limit="100 mb"/>
                     </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>
             <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
                 <transportConnector name="openwire"
                     uri="tcp://0.0.0.0:#{fedoraPropsConfig.jmsPort}?maximumConnections=1000&amp;wireformat.maxFrameSize=104857600"/>
                 <transportConnector name="stomp"
                     uri="stomp://0.0.0.0:#{fedoraPropsConfig.stompPort}"/>
            </transportConnectors>
            <!-- destroy the spring context on shutdown to stop jetty -->

            <shutdownHooks>
                 <bean xmlns="http://www.springframework.org/schema/beans"
                     class="org.apache.activemq.hooks.SpringContextHook"/>
            </shutdownHooks>
        </broker>
         <!--
           Enable web consoles, REST and Ajax APIs and demos
           Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
           <import resource="jetty.xml"/>
          -->
      </beans>

    5. Reconfigure Camel Toolbox by editing your camel toolbox properties (i.e. /opt/fedora/config/fcrepo-camel-toolbox.properties) and adding:
      jms.brokerUrl=tcp://localhost:41616
    6. Restart Camel Toolbox


  • No labels