ActiveMQ: 搭建Broker集群(cluster)
2016-09-26 09:06
435 查看
上一篇介绍了基于Networks of Borkers的2节点HA方案,这一篇继续来折腾Networks of Brokers,当应用规模日渐增长时,2节点的broker可能仍然抗不住访问压力,这时候就需要多加一些broker,弄一个更大规模的Broker集群,但是怎么合理设置broker之间的网络桥接,却是有讲究的,先来看一种不太好的设计:
<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">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker1">
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter>
<transportConnectors>
<transportConnector name="openwire"
uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
</broker>
<import resource="jetty.xml"/>
</beans>
<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">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker-hub1">
<networkConnectors>
<networkConnector uri="static:(tcp://127.0.0.1:61656,tcp://127.0.0.1:61616,tcp://127.0.0.1:61626,tcp://127.0.0.1:61636)" duplex="true"/>
</networkConnectors>
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter>
<transportConnectors>
<transportConnector name="openwire"
uri="tcp://0.0.0.0:61646?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
</broker>
<import resource="jetty.xml"/>
</beans>
<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">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker-hub2">
<networkConnectors>
<networkConnector uri="static:(tcp://127.0.0.1:61616,tcp://127.0.0.1:61626,tcp://127.0.0.1:61636)" duplex="true"/>
</networkConnectors>
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter>
<transportConnectors>
<transportConnector name="openwire"
uri="tcp://0.0.0.0:61656?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
</broker>
<import resource="jetty.xml"/>
</beans>
<bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<!--broker服务的地址-->
<property name="brokerURL" value="failover:(tcp://localhost:61646,tcp://localhost:61656)"/>
<!--默认值为1000,如果不需要这么大,可以调小-->
<property name="maxThreadPoolSize" value="100"/>
<!--<property name="userName" value="system"/>-->
<!--<property name="password" value="manager"/>-->
</bean>
</property>
</bean>
<bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<!--broker服务的地址-->
<property name="brokerURL" value="failover:(tcp://localhost:61616,tcp://localhost:61626,tcp://localhost:61636)"/>
<!--默认值为1000,如果不需要这么大,可以调小-->
<property name="maxThreadPoolSize" value="100"/>
<!--<property name="userName" value="system"/>-->
<!--<property name="password" value="manager"/>-->
</bean>
</property>
</bean>
参考文章:
http://www.jakubkorab.net/2011/11/understanding-activemq-broker-networks.html
http://activemq.apache.org/networks-of-brokers.html
相关文章推荐
- ActiveMQ笔记(4):搭建Broker集群(cluster)
- ActiveMQ笔记(4):搭建Broker集群(cluster)
- ActiveMQ集群Master-Slave + Broker Cluster模式
- Redis Cluster 初探(1) - 集群搭建与扩容
- ActiveMQ此例简单介绍基于docker的activemq安装与集群搭建
- CentOs7.3 搭建 Redis-4.0.1 Cluster 集群服务
- ActiveMQ源码解析(五):聊聊activemq的broker集群
- 手把手教你用Mysql-Cluster-7.5搭建数据库集群
- kafka环境搭建2-broker集群+zookeeper集群
- 基于zookeeper+leveldb搭建activemq集群
- 基于zookeeper+leveldb搭建activemq集群
- centos7.2 基于zookeeper集群搭建activeMQ的集群
- 在windows上搭建redis集群(redis-cluster)
- redis配置与cluster集群的搭建
- mysql集群搭建二——CentOS搭建mysql-cluster集群
- Kafka之——单机多broker实例集群搭建
- Redis学习笔记六——搭建redis集群(非分布式真正的cluster)
- 手把手教你用Mysql-Cluster-7.5搭建数据库集群
- Redis-Cluster 集群搭建(Windwos带Server启动)
- 使用MySQL-Cluster搭建MySQL数据库集群