How to setup ActiveMQ as Pure Master/Slave

tendencyrheumaticInternet και Εφαρμογές Web

12 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

497 εμφανίσεις

How to setup ActiveMQ as Pure Master/Slave


Install

http://activemq.apache.org/index.html


Based on
A
ctive
MQ

v5.6.0


Configuration

Note: This configures a master/slave on the same physical machine.


Re
ferences

http://activemq.apache.org/pure
-
master
-
slave.html



Steps

1. Create
<install>/
conf/activemq
-
master.xml

(see
here

for sample XML)

2. Create
<install>/
conf/activemq
-
slave.xml

(see
here

for sample XML)

3. in command prompt type in the following command the start the
master

broker




activemq xbean:file:../
conf/
activemq
-
master
.xml






4. in
another

command prompt, type in the following command the start the
slave

broker



activemq xbean:file:../
conf/
activemq
-
slave
.xml



Note: the slave console should show a lock on the persistent data store of the master.


The “master” br
oker should b
e active and shown

in the ActiveMQ web console
(
http://localhost:8161/admin/index.jsp
).




Confirm Configuration

As a test to ensure the master/slave is configured correctly, press CTRL
-
C in the
con
sole of the
Master

ActiveMQ broker. The ActiveMQ console for the
slave

should
become active.





The activeMQ console (
http://localhost:8161/admin/index.jsp
) should reference the
“slave” broker.




XML Config Files


Master (activemq
-
master.xml)


<beans


xmlns="http://www.springframework.org/schema/beans"


xmlns:amq="http://activemq.apache.org/schema/core"


xmlns:xsi="http://www.w3.org/2001/XMLSchema
-
instance"


xsi:schemaLocation="http://www.spr
ingframework.org/schema/beans
http://www.springframework.org/schema/beans/spring
-
beans
-
2.0.xsd


http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq
-
core.xsd">



<!
--

Allows us to use system properties as variables in
this configuration file
--
>


<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">


<property name="locations">


<value>file:${activemq.conf}/credentials.properties</value>


</property>


</bean
>



<!
--


The <broker> element is used to configure the ActiveMQ broker.


--
>


<broker xmlns="http://activemq.apache.org/schema/core" brokerName="master"
dataDirectory="${activemq.data}">


<destinationPolicy>


<policyMap>


<policyEntries>


<policyEntry topic=">" producerFlowControl="true" memoryLimit="1mb">


<pendingSubscriberPolicy>


<vmCursor />


</pendingSubscriberPolicy>


</p
olicyEntry>


<policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb">


</policyEntry>


</policyEntries>


</policyMap>


</destinationPolicy>



<managementContext>


<m
anagementContext createConnector="false"/>


</managementContext>



<!
--


Configure message persistence for the broker.


--
>


<persistenceAdapter>


<kahaDB directory="${activemq.data}/kahadb/master
-
slave"/>


</persistenceAdapter>



<systemUsage>


<systemUsage>


<memoryUsage>


<memoryUsage limit="64 mb"/>


</memoryUsage>


<storeUsage>


<storeUsage lim
it="100 gb"/>


</storeUsage>


<tempUsage>


<tempUsage limit="50 gb"/>


</tempUsage>


</systemUsage>


</systemUsage>



<!
--


The transport connectors expose
ActiveMQ over a given protocol to


clients and other brokers.


--
>


<transportConnectors>


<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>



<transportConnector name="stomp"
uri="stomp://0.0.0.0:61612
?transport.closeAsync=false"/>


<transportConnector name="stomp+nio"
uri="stomp+nio://0.0.0.0:61613?transport.closeAsync=false"/>


<transportConnector name="websocket" uri="ws://0.0.0.0:61614"/>


</transportConnectors>



</b
roker>



<!
--


Enable web consoles, REST and Ajax APIs and demos


--
>


<import resource="jetty.xml"/>


</beans>


Slave (activemq
-
slave.xml)


<beans


xmlns="http://www.springframework.org/schema/beans"


xmlns:amq="http://activemq.apache.o
rg/schema/core"


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
-
2.0.xsd


http://activemq.apache.org/schema/core
http://activ
emq.apache.org/schema/core/activemq
-
core.xsd">



<!
--

Allows us to use system properties as variables in this configuration file
--
>


<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">


<property name="locati
ons">


<value>file:${activemq.conf}/credentials.properties</value>


</property>


</bean>



<!
--


The <broker> element is used to configure the ActiveMQ broker.


--
>


<broker xmlns="http://activemq.apache.org/schema/core
" brokerName="slave"
dataDirectory="${activemq.data}"


masterConnectorURI="tcp://0.0.0.0:61616" shutdownOnMasterFailure="false">



<destinationPolicy>


<policyMap>


<policyEntries>


<policyEntry topic=">"
producerFlowControl="true" memoryLimit="1mb">


<pendingSubscriberPolicy>


<vmCursor />


</pendingSubscriberPolicy>


</policyEntry>


<policyEntry queue=">" producerFlowContro
l="true" memoryLimit="1mb">


</policyEntry>


</policyEntries>


</policyMap>


</destinationPolicy>



<managementContext>


<managementContext createConnector="false"/>


</managementContex
t>



<persistenceAdapter>


<kahaDB directory="${activemq.data}/kahadb/master
-
slave"/>


</persistenceAdapter>



<systemUsage>


<systemUsage>


<memoryUsage>


<memoryUsage limit="6
4 mb"/>


</memoryUsage>


<storeUsage>


<storeUsage limit="100 gb"/>


</storeUsage>


<tempUsage>


<tempUsage limit="50 gb"/>


</tempUsage>



</systemUsage>


</systemUsage>



<!
--


The transport connectors expose ActiveMQ over a given protocol to


clients and other brokers.


--
>


<transportConnectors>


<transportConnector name=
"openwire" uri="tcp://0.0.0.0:61626"/>



<transportConnector name="stomp"
uri="stomp://0.0.0.0:61622?transport.closeAsync=false"/>


<transportConnector name="stomp+nio"
uri="stomp+nio://0.0.0.0:61623?transport.closeAsync=false"/>


<transportConnector name="websocket" uri="ws://0.0.0.0:61624"/>


</transportConnectors>



</broker>



<!
--


Enable web consoles, REST and Ajax APIs and demos


--
>


<import resource="jetty.xml"/>


</beans>