ActiveMQ配置mysql
官方文档:http://activemq.apache.org/persistence.html
1.配置activemq.xml(在apache-activemq-5.15.8\conf下)
(1)打开activemq.xml,在broker节点下添加
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"/>
<jdbcPersistenceAdapter dataSource="#mysql-ds"/>
</persistenceAdapter>
(2)在beans下添加
<!--配置数据源-->
<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://localhost/activemq?relaxAutoCommit=true"/>
<property name="username" value="username"/>
<property name="password" value="password"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
2.添加mysql连接jar包到apache-activemq-5.15.8\lib下
3.启动activemq就会在mysql生成三个表(activemq数据库需自己创建 )
这里只对activemq_acks、activemq_msgs说明
5.启动代码即可成功