ActiveMq 消息持久化到MySql数据库
1、修改 conf/activemq.xml配置文件
<persistenceAdapter> <kahaDB directory="${activemq.data}/kahadb"/> </persistenceAdapter>
将默认的配置改成
<persistenceAdapter> <jdbcPersistenceAdapter dataSource="#my-ds"/> </persistenceAdapter>
2、添加bean配置
<bean id="my-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:3306/activemq?useUnicode=true&characterEncoding=UTF-8" /> <property name="username" value="username" /> <property name="password" value="password" /> <property name="maxTotal" value="100" /> <property name="poolPreparedStatements" value="true"/> </bean>
3、添加数据库驱动
将数据驱动包复制到lib目录下
4、新增数据
5、重新启动服务