ActiveMQ 集群和主从
举例说明:
假设有 3 个 broker 节点,分别是61616,61618, 61620,其中 61616 和 61618 组成主、从节点,而 61616(或61618)和 61620 构成集群。
61616 和 61618 使用 jdbc 持久化,61620 使用 kahaDB。
这样混合配置:能更好地理解主从和集群的区别,61616 和 61618 在同一时刻只有一个 broker 提供服务,而集群是同时在提供服务,消息在集群的节点之间流转。
61616 配置:
<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-2.0.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd"> <broker useJmx="false" brokerName="jdbcBroker61616" xmlns="http://activemq.apache.org/schema/core">
<persistenceAdapter>
<jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#mysql-ds"/>
</persistenceAdapter> <networkConnectors>
<networkConnector uri="multicast://default"
dynamicOnly="true"
networkTTL="3"
prefetchSize="1"
decreaseNetworkConsumerPriority="true" />
</networkConnectors> <transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616" discoveryUri="multicast://default"/>
</transportConnectors>
</broker> <!-- MySql DataSource Sample Setup -->
<bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://192.168.40.8:3306/db_zhang?relaxAutoCommit=true"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
<property name="maxActive" value="200"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
</beans>
61618 配置:
<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-2.0.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd"> <broker useJmx="false" brokerName="jdbcBroker61618" xmlns="http://activemq.apache.org/schema/core">
<persistenceAdapter>
<jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#mysql-ds"/>
</persistenceAdapter>
<networkConnectors>
<networkConnector uri="multicast://default"
dynamicOnly="true"
networkTTL="3"
prefetchSize="1"
decreaseNetworkConsumerPriority="true" />
</networkConnectors> <transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61618" discoveryUri="multicast://default"/>
</transportConnectors>
</broker> <!-- MySql DataSource Sample Setup -->
<bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://192.168.40.8:3306/db_zhang?relaxAutoCommit=true"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
<property name="maxActive" value="200"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
</beans>
61620 配置:
<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.springframework.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
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:mq.properties"/>
</bean> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="dynamic-broker2" dataDirectory="${activemq.base}/data"> <!-- Destination specific policies using destination names or wildcards -->
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue=">" producerFlowControl="true" memoryLimit="20mb">
<deadLetterStrategy>
<individualDeadLetterStrategy queuePrefix="DLQ." useQueueForQueueMessages="true" />
</deadLetterStrategy>
</policyEntry>
<policyEntry topic=">" producerFlowControl="true" memoryLimit="20mb">
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy> <!-- Use the following to configure how ActiveMQ is exposed in JMX -->
<managementContext>
<managementContext createConnector="true" connectorPort="1100"/>
</managementContext> <!--
Configure network connector to use multicast protocol
For more information, see http://activemq.apache.org/multicast-transport-reference.html
-->
<networkConnectors>
<networkConnector uri="multicast://default"
dynamicOnly="true"
networkTTL="3"
prefetchSize="1"
decreaseNetworkConsumerPriority="true" />
</networkConnectors> <persistenceAdapter>
<kahaDB directory="${activemq.base}/data/dynamic-broker2/kahadb" />
</persistenceAdapter> <!-- The maximum amount of space the broker will use before slowing down producers -->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="20 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb" name="foo"/>
</storeUsage>
<tempUsage>
<tempUsage limit="100 mb"/>
</tempUsage>
</systemUsage>
</systemUsage> <!--
The transport connectors ActiveMQ will listen to
Configure discovery URI to use multicast protocol
-->
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61620" discoveryUri="multicast://default" />
</transportConnectors> </broker>
</beans>
其中一个 producer 配置:
new ActiveMQConnectionFactory("failover:(tcp://localhost:61616,tcp://localhost:61618)");
其中一个 consumer 配置:
new ActiveMQConnectionFactory("tcp://localhost:61620");
producer 往(61616主,61618从)发送消息,consumer 可以从 61620 获取消息。当 61616 下线后,61618 会成为主,并和 61620 构成集群。
ActiveMQ 集群和主从的更多相关文章
- ActiveMQ(七)_伪集群和主从高可用使用
一.本文目的 介绍如何在同一台虚拟机上搭建高可用的Activemq服务,集群数量包含3个Activemq,当Activemq可用数>=2时,整个集群可用. 本 ...
- ActiveMQ(七)_伪集群和主从高可用使用(转)
本文转自: https://www.cnblogs.com/gossip/p/5977489.html 一.本文目的 介绍如何在同一台虚拟机上搭建高可用的Activemq服务,集群数量 ...
- 使用jmeter对ActiveMQ集群性能方案进行评估--转载
原文地址:http://www.51testing.com/html/78/23978-143163.html 1.测试概要1.1 关于这篇文档中涉及的基于JMS的消息系统能为应用程序提供可靠的,高性 ...
- ActiveMQ集群整体认识
出自:https://segmentfault.com/a/1190000014592517 前言 最终需要掌握 Replicated LevelDB Store部署方式,这种部署方式是基于ZooKe ...
- 消息队列--ActiveMQ集群部署
一.activeMQ主要的部署方式? 1,默认的单机部署(kahadb) activeMQ默认的存储单机模式,如果配置文件不做修改,则默认使用此模式.以本地的kahadb文件的方式进行存储,性能完全依 ...
- ActiveMQ集群应用
ActiveMQ集群 ActiveMQ具有强大和灵活的集群功能,但在使用的过程中会发现很多的缺点,ActiveMQ的集群方式主要由两种:Master-Slave和Broker Cluster. 1.M ...
- 分布式ActiveMQ集群
分布式ActiveMQ集群的部署配置细节: 官方资料:http://activemq.apache.org/clustering.html 基本上看这个就足够了,本文就不具体分析配置文件了. 1.Qu ...
- ActiveMQ集群(2)
ActiveMQ具有强大和灵活的集群功能,但在使用的过程中会发现很多的缺点,ActiveMQ的集群方式主要有两种:Master-Slave和Broker Cluster. 1.Master-Slave ...
- 分布式ActiveMQ集群--转载
原文地址:http://shensy.iteye.com/blog/1752529 回顾总结前一段时间学习的ActiveMQ分布式集群相关的知识,分享出来希望对看到的人有所帮助. 一.分布式Activ ...
随机推荐
- latex建立参考文献的超链接
在Latex生成的pdf文档中建立超链接(如从正文到参考文献,从目录到相应内容,从页码编号到实际页面等),有利于读者快速定位当前阅读的信息. 如何在生成的pdf文件中包含超链接呢?需要注意一下两点: ...
- 抗性基因数据库CARD介绍
随着抗生素药物的发现及使用,越来越多的耐药菌株由此产生.而耐药菌株的发展则会增加疾病治疗的难度和成本,因此耐药微生物的研究则显得尤为重要.目前,通过对耐药基因的鉴定挖掘能够一定程度上帮助我们揭开耐药机 ...
- vue运行报错--dependency
ERROR Failed to compile with 1 errors 11:17:27 This dependency was not found: 解决方法:把报错所缺少的依赖都装上 如 xx ...
- Windows下Oracle创建数据库的3种方式
1. Creating a Database with DBCA DatabaseConfiguration Assistant (DBCA) is the preferred way to cr ...
- L1-048. 矩阵A乘以B
水题不多说,直接上代码:#include<stdio.h> using namespace std; int main() { ][]; ][]; int m,n; int x,y; sc ...
- red hat7 系统可以ping通ip地址但是不能ping通域名
在red hat7中ifconfig后出现这样的情况,ens33是物理网卡,与eth0一样只是不同的名字.但是只能ping通ip地址不能ping通域名. 解决方法: 在文件 /etc/resolv.c ...
- x1c 2018 体验
总结一下: 2018对比2017优点: 1屏幕完爆:HDR WHD镜面屏完爆 FHD 雾面屏(污+雾,所谓的油腻感),还有色彩!正红色第一次觉得这么好看.别人看得出来看不出来我不知道,至少我能看出来非 ...
- TortoiseSVN上传cocos2dx的项目不能打包的问题!
由于TortoiseSVN默认是忽略 *.a的,导致上传的项目文件缺少所有的*.a文件. 在TortoiseSVN->Settings->General->Global ignore ...
- Netty实现简易http_server
Netty可以通过一些handler实现简单的http服务器.具体有三个类,分别是HttpServer.java.ServerHandlerInit.java.BusiHandler.java. 具体 ...
- ffmpeg 无损改变纵横比aspect
最后发觉, potplayer 里 Ctrl+Enter 或者 Enter 可以扩展到整个屏幕/保持比例,根本不需要额外去转换 如果整个视频都要改的话,把 -ss -t 参数去掉 ffmpeg -ss ...