1、jdbcPersistenceAdapter数据库存储
<persistenceAdapter>
<jdbcPersistenceAdapter dataSource="#mysql-ds" createTablesOnStartup="true"/>
</persistenceAdapter>
注:红色标记的地方,第一次启动时建议设置成true,会自动生成 activemq_msgs/activemq_lock/activemq_acks三张表,同时需要注意,不同的activemq版本,表结构会有所区别.表生成之后,必须将其设置成false.
<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:3306/activemq?relaxAutoCommit=true"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
<property name="maxTotal" value="200"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
注:红色标记的地方,是针对不同的dbcp版本而言的.如果是版本1.*,则是org.apache.commons.dbcp.BasicDataSource
更多参数设置请参考:http://blog.csdn.net/fairyhawk/article/details/7565391
2、memoryPersistenceAdapter 内存存储
<persistenceAdapter>
<memoryPersistenceAdapter/>
</persistenceAdapter>
或者将persistent=false。
<broker brokerName="test-broker" persistent="false" xmlns="http://activemq.apache.org/schema/core">
3、kahaDB文件存储
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter>
4、journalPersistenceAdapter文件存储
<persistenceAdapter>
<journaledJDBC dataDirectory="${activemq.base}/data" dataSource="#postgres-ds"/>
</persistenceAdapter>
适用场景:对于集群的broker用JDBC的消息和日志存储,可以有效的避免数据丢失.
5、mKahaDB文件存储
<persistenceAdapter>
<mKahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter>
6、replicatedLevelDB文件存储
<persistenceAdapter>
<replicatedLevelDB
directory="${activemq.data}"
replicas="2"
bind="tcp://0.0.0.0:61619"
zkAddress="127.0.0.1:2181"
zkPassword="password"
zkPath="/activemq/leveldb-stores"
/>
</persistenceAdapter>
7、levelDB文件存储
<persistenceAdapter>
<levelDB directory="${activemq.data}/leveldb"/>
</persistenceAdapter>
参考:https://blog.51cto.com/881206524/1927604
原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/tech/opensource/195046.html