Question

We are trying to set up the active MQ cluster on production environment on Amazon EC2 with Auto discover and multicast. I was able to configure successfully auto discovery with multi-cast on my local active mq server but on Amazon EC2 it is not working.

From the link I found that Amazon EC2 does not support multi-cast. Hence we have to use HTTP transport or VPN for multi-cast. I tried HTTP transport for multi-cast by downloading activemq-optional-5.6.jar (we are using Active-MQ 5.6 version). It requires httpcore and httpClient jars to servlet in it class path.

In broker configuration(activemq.xml)

`
    <networkConnectors>
        <networkConnector name="default" uri="http://localhost:8161/activemq/DiscoveryRegistryServlet"/>
    </networkConnectors>

    <transportConnectors>
        <transportConnector name="activemq" uri="tcp://localhost:61616" discoveryUri="http://localhost:8161/activemq/DiscoveryRegistryServlet"/>
    </transportConnectors>`

are added.

But broker is not identifying the DiscoveryRegistryServlet.

Any help is much appreciated.

Was it helpful?

Solution

Finally figured out how to setup active MQ auto discovery with HTTP

Active-MQ Broker configuration:

  1. In $ACTIVEMQ_HOME/webapps folder create a new folder
|_activemq
      |_WEB-INF
             |_classes
             |_web.xml

create a web.xml file with the following contents

    <web-app>

        <display-name>ActiveMQ Message Broker Web Application</display-name>
        <description>
            Provides an embedded ActiveMQ Message Broker embedded inside a web application
        </description>

        <!-- context config -->
        <context-param>
            <param-name>org.apache.activemq.brokerURL</param-name>
            <param-value>tcp://localhost:61617</param-value>
            <description>The URL that the embedded broker should listen on in addition to HTTP</description>
        </context-param>
        <!-- servlet mappings -->
        <servlet>
            <servlet-name>DiscoveryRegistryServlet</servlet-name>
            <servlet-class>org.apache.activemq.transport.discovery.http.DiscoveryRegistryServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
            <servlet-name>DiscoveryRegistryServlet</servlet-name>
            <url-pattern>/*</url-pattern>
    </servlet-mapping>
    </web-app>
  1. Place httpclient-4.0.3.jar, httpcore-4.3.jar, xstream-1.4.5.jar and activemq-optional-5.6.0.jar in $ACTIVEMQ_HOME/lib directory.

  2. In $ACTIVEMQ_HOME/config directory, modify the jetty.xml file to expose activemq web app.

    <bean id="securityHandler" class="org.eclipse.jetty.security.ConstraintSecurityHandler">
        ...
        <property name="handler">
                <bean id="sec" class="org.eclipse.jetty.server.handler.HandlerCollection">
                    <property name="handlers">
                ...
                ...
                <bean class="org.eclipse.jetty.webapp.WebAppContext">
                                        <property name="contextPath" value="/activemq" />
                                        <property name="resourceBase" value="${activemq.home}/webapps/activemq" />
                                        <property name="logUrlOnStart" value="true" />
                                        <property name="parentLoaderPriority" value="true" />
                    ...
                    ...
                </list>
                    </property>
                </bean>
            </property>
        </bean>
  1. Modify activemq.xml file in $ACTIVEMQ_HOME/conf directory to use http protocol
    <broker name=”brokerName”>
    ...
     <networkConnectors>
          <networkConnector name="default" uri="http://<loadbalancer_IP>:<locadbalancer_Port>/activemq/DiscoveryRegistryServlet?group=test"/>
          <!--<networkConnector name="default-nc" uri="multicast://default"/>-->
           </networkConnectors>

        <transportConnectors>
            <transportConnector name="http" uri="tcp://0.0.0.0:61618" discoveryUri="http://<loadbalancer_IP>:<locadbalancer_Port>/activemq/test"/>
        </transportConnectors>
    ...
    </broker>

make sure that the broker names are unique. “test” in url is the group name of brokers. Client configuration: 1. Keep httpclient-4.0.3.jar, httpcore-4.3.jar, xstream-1.4.5.jar and activemq-optional-5.6.0.jar in classpath of client 2. URL to be use by client

    discovery:(http://<loadbalancer_IP>:<locadbalancer_Port>/activemq/test)connectionTimeout=10000

here “test” is the group name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top