Introduction
In my previous posts, I have covered tutorial about ActiveMQ with the following aspects:
- Installation: ActiveMQ 5.10.0 Installation And Configuration
- Configure Master-Slave Cluster for High Availability: http://ggl-consulting.blogspot.com/2015/01/configure-activemq-for-high-available.html
- Montoring ActiveMQ Using jVisualVM: http://ggl-consulting.blogspot.com/2015/01/monitor-activemq-nodes-using-jmx.html
- Monitoring ActiveMQ Using Tomcat: http://ggl-consulting.blogspot.com/2015/01/monitoring-activemq-using-tomcat-web.html
I have explained how master-slave paradigm with shared file system works. In this post, I will explain more advanced topic, namely, Network Of Brokers. I will demonstrate the procedures to setup a network of ActiveMQ brokers with Master-Slave pairs.
Network Topology
As shown in the above figure, I configured two clusters. The WEST cluster contains two ActiveMQ nodes, namely, north and south. These two node forms a master-slave pair. Depending on applications, the nodes number could be 2 or 3. These nodes sharing the same NFS where the kahaDB is located. The same is for the EAST cluster.
Configurations
Directory Layout
The ActiveMQ is installed at:
1 | /opt/app/activemq/apache-activemq-5.10.0 |
The tomcat is installed at:
1 | /opt/app/activemq/cluster/master-slave/tomcat/apache-tomcat-8.0.17 |
north and south nodes
1 2 | /opt/app/amq/NetworkOfBrokers/cluster/north /opt/app/amq/NetworkOfBrokers/cluster/south |
activemq.xml
To setup network of brokers as shown in the introduction, we just need to update the activemq.xml file from west cluster. The file contents is as the following:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | 1 <!--xml version= "1.0" encoding= "UTF-8" ?--> 2 3 <beans xmlns= "http://www.springframework.org/schema/beans" 4= "" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" 5= "" xsi:schemalocation= "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http:/ /activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd" > 6 7 <bean class= "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" > 8 <property name= "locations" > 9 <value>file:${activemq.conf}/credentials.properties</value> 10 </property> 11 </bean> 12 13 <bean class= "org.fusesource.insight.log.log4j.Log4jLogQuery" 14= "" destroy-method= "stop" 15= "" id= "logQuery" 16= "" init-method= "start" 17= "" lazy-init= "false" 18= "" scope= "singleton" > 19 </bean> 20 21 <broker xmlns= "http://activemq.apache.org/schema/core" 22= "" brokername= "WEST-NORTH" 23= "" datadirectory= "${activemq.data}" 24= "" usejmx= "true" > 25 26 <destinationpolicy> 27 <policymap> 28 <policyentries> 29 <policyentry queue= ">" > 30 <networkbridgefilterfactory> 31 <conditionalnetworkbridgefilterfactory replaywhennoconsumers= "true" > 32 </conditionalnetworkbridgefilterfactory></networkbridgefilterfactory> 33 <pendingmessagelimitstrategy> 34 <constantpendingmessagelimitstrategy limit= "1000" > 35 </constantpendingmessagelimitstrategy></pendingmessagelimitstrategy> 36 </policyentry> 37 <policyentry topic= ">" > 38 <pendingmessagelimitstrategy> 39 <constantpendingmessagelimitstrategy limit= "1000" > 40 </constantpendingmessagelimitstrategy></pendingmessagelimitstrategy> 41 </policyentry> 42 </policyentries> 43 </policymap> 44 </destinationpolicy> 45 46 <managementcontext> 47 <managementcontext connectorport= "11099" createconnector= "true" rmiserverport= "44444" > 48 </managementcontext> 49 50 <networkconnectors> 51 <networkconnector 52= "" uri= "masterslave://(tcp://sandboxfusev02:61616,tcp://sandboxfusev02:61626)" 53= "" name= "Queue_Connector" 54= "" decreasenetworkconsumerpriority= "true" 55= "" conduitsubscriptions= "false" 56= "" suppressduplicatequeuesubscriptions= "true" 57= "" networkttl= "2" 58= "" messagettl= "2" 59= "" consumerttl= "2" 60= "" duplex= "true" 61= "" staticbridge= "false" > 62 63 <dynamicallyincludeddestinations> 64 </dynamicallyincludeddestinations> 65 66 <excludeddestinations> 67 <topic physicalname= ">" > 68 </topic></excludeddestinations> 69 </networkconnector> 70 <networkconnector 71= "" uri= "masterslave://(tcp://sandboxfusev02:61616,tcp://sandboxfusev02:61626)" 72= "" name= "Topic_Connector" 73= "" decreasenetworkconsumerpriority= "true" 74= "" conduitsubscriptions= "true" 75= "" suppressduplicatequeuesubscriptions= "true" 76= "" networkttl= "2" 77= "" messagettl= "2" 78= "" consumerttl= "2" 79= "" duplex= "true" 80= "" staticbridge= "false" > 81 82 <dynamicallyincludeddestinations> 83 </dynamicallyincludeddestinations> 84 85 <excludeddestinations> 86 <queue physicalname= ">" > 87 </queue></excludeddestinations> 88 </networkconnector> 89 </networkconnectors> 90 91 <persistenceadapter> 92 <kahadb directory= "/amqdata/networkofbrokers/west-cluster/data" > 93 </kahadb></persistenceadapter> 94 95 <systemusage> 96 <systemusage> 97 <memoryusage> 98 <memoryusage percentofjvmheap= "70" > 99 </memoryusage> 100 <storeusage> 101 <storeusage limit= "100 gb" > 102 </storeusage> 103 <tempusage> 104 <tempusage limit= "50 gb" > 105 </tempusage> 106 </tempusage></storeusage></memoryusage></systemusage> 107 </systemusage> 108 109 <transportconnectors> 110 <transportconnector name= "openwire" uri= "tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600" > 111 <transportconnector name= "amqp" uri= "amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600" > 112 <transportconnector name= "stomp" uri= "stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600" > 113 <transportconnector name= "mqtt" uri= "mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600" > 114 <transportconnector name= "ws" uri= "ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600" > 115 </transportconnector></transportconnector></transportconnector></transportconnector></transportconnector></transportconnectors> 116 117 <shutdownhooks> 118 <bean xmlns= "http://www.springframework.org/schema/beans" class= "org.apache.activemq.hooks.SpringContextHook" > 119 </bean></shutdownhooks> 120 121 </managementcontext></broker> 122 </beans> |
From the above configuration, you can see that I have configured two network connections, namely, Queue_Connector and Topic_Connector. Copy this activemq.xml to both north and south nodes, and leave the east cluster as it is as show my my previous blog of pure master-slave clustering.