ActiveMQ此例简单介绍基于docker的activemq安装与集群搭建
ActiveMQ拓展连接此例简单介绍基于docker的activemq安装与集群搭建一 :安装1.获取activemq镜像docker pull webcenter/activemq2.启动容器docker run --name activemq -p 61616:61616 -e ACTIVEMQ_ADMIN_LOGIN=admin -e ACTIVEMQ_ADMIN_PASSWORD
·
ActiveMQ拓展连接
此例简单介绍基于docker的activemq安装与集群搭建
一 :安装
1.获取activemq镜像
docker pull webcenter/activemq
2.启动容器
docker run --name activemq -p 61616:61616 -e ACTIVEMQ_ADMIN_LOGIN=admin -e ACTIVEMQ_ADMIN_PASSWORD=123 --restart=always -d activemq:latest
二 :集群搭建
1.activemq.xml
<beans
xmlns="http://www.springframework.org/schema/beans"
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.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>
<!-- Allows accessing the server log -->
<bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"
lazy-init="false" scope="singleton"
init-method="start" destroy-method="stop">
</bean>
<!--
The <broker> element is used to configure the ActiveMQ broker.
-->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" >
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000"></constantPendingMessageLimitStrategy>
</pendingMessageLimitStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
<managementContext>
<managementContext createConnector="false"></managementContext>
</managementContext>
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"></kahaDB>
</persistenceAdapter>
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70" ></memoryUsage>
</memoryUsage>
<storeUsage>
<storeUsage limit="100 gb"></storeUsage>
</storeUsage>
<tempUsage>
<tempUsage limit="50 gb"></tempUsage>
</tempUsage>
</systemUsage>
</systemUsage>
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"></transportConnector>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"></transportConnector>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"></transportConnector>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"></transportConnector>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"></transportConnector>
</transportConnectors>
<!-- destroy the spring context on shutdown to stop jetty -->
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" ></bean>
</shutdownHooks>
</broker>
<import resource="jetty.xml"></import>
</beans>
2.首先在Broker-A节点中添加networkConnector节点
<networkConnectors>
<networkConnector uri="static:(tcp://0.0.0.0:61617)" userName="admin" password="123" duplex="false" ></networkConnector>
</networkConnectors>
3.修改Broker-A节点中的服务提供端口为61616
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600" ></transportConnector>
</transportConnectors>
4.在Broker-B节点中添加networkConnector节点
<networkConnectors>
<networkConnector uri="static:(tcp:// 0.0.0.0:61616)" userName="admin" password="123" duplex="false" ></networkConnector>
</networkConnectors>
5.修改Broker-A节点中的服务提供端口为61616
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600" ></transportConnector>
</transportConnectors>
6.分别启动容器
docker run --name activemq1 -p 61616:61616 -v /showcase/activemq/activemq1.xml:/opt/activemq/conf/activemq.xml -e ACTIVEMQ_ADMIN_LOGIN=admin -e ACTIVEMQ_ADMIN_PASSWORD=123 --restart=always -d activemq:latest
docker run --name activemq2 -p 61617:61616 -v /showcase/activemq/activemq2.xml:/opt/activemq/conf/activemq.xml -e ACTIVEMQ_ADMIN_LOGIN=admin -e ACTIVEMQ_ADMIN_PASSWORD=123 --restart=always -d activemq:latest
更多推荐
已为社区贡献3条内容
所有评论(0)