You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by rnazneen <ru...@gmail.com> on 2013/11/21 07:01:25 UTC

Re: Discovery without multicast (like on EC2)

This may help someone who wants to setup active mq auto discovery on EC2. 

*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>

2. 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.

3. 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>

4. 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.




--
View this message in context: http://activemq.2283324.n4.nabble.com/Discovery-without-multicast-like-on-EC2-tp3658967p4674710.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Discovery without multicast (like on EC2)

Posted by vamit100 <va...@gmail.com>.
Hi,

I tried above mentioned broker configuration with activemq 5.14.1 . But it
is not working. I have three brokers and HAproxy as a load balancer.

Suppose broker1IP, broker2IP, broker3IP are ip addresses of brokers and
haproxyIP is ip address HAProxy VM. 61616 is openwire port for activemq.
(Note : All brokers are on different machines. Also there is separate
machine for HAProxy)

In addition to above mentioned configuration, here is customized
configuration on my side.

*1. HAProxy Configuration file*

defaults
    mode tcp
	
frontend MessagingBroker
    bind *:61616
    default_backend nodes
    
backend nodes
    balance roundrobin
    server web01 broker1IP:61616 check
    server web02 broker2IP:61616 check
    server web03 broker3IP:61616 check

listen stats *:8080
    mode http
    stats enable
    stats uri /
    stats hide-version
    stats auth admin:admin

frontend discovery
    mode http
    bind *:61618
    default_backend discovery_nodes
    
backend discovery_nodes
    mode http
    balance roundrobin
    server web01 broker1IP:61618 check
    server web02 broker2IP:61618 check
    server web03 broker3IP:61618 check
*
2. Addition of network connector in activemq.xml file
*

<networkConnectors> 
              <networkConnector name="default"
uri="http://haproxyIP:61618/activemq/DiscoveryRegistryServlet?group=test"/> 
               </networkConnectors>

*3. Addition of new transport connector:* Addition of below transport
connector to activemq.xml file. This is in addition to Openwire transport
connector. I just added below new transport connector for http discovery.

 <transportConnectors> 
                    <transportConnector name="http"
uri="tcp://0.0.0.0:61618"
discoveryUri="http://haproxyIP:61618/activemq/test"/> 
                </transportConnectors> 


*4. I have not added any jars as all optional jars are already present in
activemq 5.14.1 . *


       Using this configuration, I am able to successfully connect to
different different brokers using uri failover:(tcp://haproxyIP:61616) from
client side. This means that HAProxy is working fine. But, these three
brokers are not getting inter-connected to each other using http discovery.
I want to create network of brokers.

Please let me know how can I successfully create network of brokers using
http discovery.

Thanks for Help. 



--
View this message in context: http://activemq.2283324.n4.nabble.com/Discovery-without-multicast-like-on-EC2-tp3658967p4719319.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.