ActiveMQ 消息持久化到Mysql数据库

一、下载ActiveMQ

版本:ActiveMQ 5.15.3 Release

地址:http://activemq.apache.org/download.html

二、运行ActiveMQ

1、解压apache-activemq-5.15.3-bin.zip

2、执行\bin\win64\activemq.bat脚本即可启动AMQ

三、修改配置文件持久化到Mysql数据库

文件路径:\conf\activemq.xml

 1 <!--
 2     Configure message persistence for the broker. The default persistence
 3     mechanism is the KahaDB store (identified by the kahaDB tag).
 4     For more information, see:
 5 
 6     http://activemq.apache.org/persistence.html
 7 -->
 8 <persistenceAdapter>
 9     <!--<kahaDB directory="${activemq.data}/kahadb"/>-->
10     <jdbcPersistenceAdapter dataSource="#mysql-ds"/>
11 </persistenceAdapter>
 1 <bean id="mysql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
 2     <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
 3     <property name="url" value="jdbc:mysql://localhost:3306/db_activemq?relaxAutoCommit=true"/>
 4     <property name="username" value="root"/>
 5     <property name="password" value="root"/>
 6     <property name="poolPreparedStatements" value="true"/>
 7 </bean>
 8 
 9 <!--
10     Enable web consoles, REST and Ajax APIs and demos
11     The web consoles requires by default login, you can disable this in the jetty.xml file
12 
13     Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
14 -->
15 <import resource="jetty.xml"/>

四、引入Mysql包

复制mysql-connector-java-5.1.45.jar包到\lib\目录下

五、重新运行AMQ,数据库自动生成3张表

activemq_acks:用于存储订阅关系。如果是持久化Topic,订阅者和服务器的订阅关系在这个表保存

activemq_lock:在集群环境中才有用,只有一个Broker可以获得消息,称为Master Broker

activemq_msgs:用于存储消息,Queue和Topic都存储在这个表中

 

转载于:https://www.cnblogs.com/sjshare/p/8962948.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值