1.将mysql jar包拷贝到myactiveMQ/lib/ 文件夹下
cp mysql-connector-java-5.1.38.jar /myactiveMQ/apache-activemq-5.15.9/lib/
2.在 /myactiveMQ/apache-activemq-5.15.9/conf路径下修改activemq.xml文件
<persistenceAdapter> <!--<kahaDB directory="${activemq.data}/kahadb"/>--> <jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#mysql-ds"/>
</persistenceAdapter>
<!--支持高速缓存的配置。需要将上方persistenceAdapter标签注释掉-->
<persistenceFactory> <journalPersistenceAdapterFactory journalLogFiles="4" journalLogFileSize="32768" useJournal="true" useQuickJournal="true" dataSource="#mysql-ds" dataDirectory="activemq-data"/> </persistenceFactory>
3.修改activemq.xml文件(<import resource="jetty.xml"/>标签之前)
<bean id="mysql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://192.168.1.224:3306/activemq?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&relaxAutoCommit=true"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
4.创建activemq数据库,后重新启动activemq会自动生成对应表