2

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)

`
    &ltnetworkConnectors>
        &ltnetworkConnector name="default" uri="http://localhost:8161/activemq/DiscoveryRegistryServlet"/>
    &lt/networkConnectors>

    &lttransportConnectors>
        &lttransportConnector name="activemq" uri="tcp://localhost:61616" discoveryUri="http://localhost:8161/activemq/DiscoveryRegistryServlet"/>
    &lt/transportConnectors>`

are added.

But broker is not identifying the DiscoveryRegistryServlet.

Any help is much appreciated.

R Nazneen
  • 51
  • 1
  • 7

1 Answers1

3

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

    &ltweb-app>

        &ltdisplay-name>ActiveMQ Message Broker Web Application&lt/display-name>
        &ltdescription>
            Provides an embedded ActiveMQ Message Broker embedded inside a web application
        &lt/description>

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

        &ltservlet-mapping>
            &ltservlet-name>DiscoveryRegistryServlet&lt/servlet-name>
            &lturl-pattern>/*&lt/url-pattern>
    &lt/servlet-mapping>
    &lt/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.

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

        &lttransportConnectors>
            &lttransportConnector name="http" uri="tcp://0.0.0.0:61618" discoveryUri="http://&ltloadbalancer_IP>:&ltlocadbalancer_Port>/activemq/test"/>
        &lt/transportConnectors>
    ...
    &lt/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://&ltloadbalancer_IP>:&ltlocadbalancer_Port>/activemq/test)connectionTimeout=10000

here “test” is the group name.

R Nazneen
  • 51
  • 1
  • 7
  • Comment from [Ranka Nair](https://stackoverflow.com/users/4191876/ranka-nair): The correct `networkConnectorURI` is the same as the transport URI (../activemq/test) – Jason Baker Oct 28 '14 at 22:38
  • This solution is excellent, but I have one question, when I look into activeMQ admin, inside "Queues", I can see the messages are enqued, but they are not dequed. Do you know why this happens ? Any solution ? – roneo Feb 23 '16 at 08:12