ActiveMQ message persistence to Mysql database

1. Download ActiveMQ

Version: ActiveMQ 5.15.3 Release

Address: http://activemq.apache.org/download.html

2. Running ActiveMQ

1. Unzip apache-activemq-5.15.3-bin.zip

2. Execute the \bin\win64\activemq.bat script to start AMQ

3. Modify the configuration file and persist it to the Mysql database

File path: \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"/>

Fourth, the introduction of the Mysql package

Copy the mysql-connector-java-5.1.45.jar package to the \lib\ directory

Five, re-run AMQ, the database automatically generates 3 tables

activemq_acks:

activemq_lock:

activemq_msgs:

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324972067&siteId=291194637