Official documentation: http://activemq.apache.org/persistence.html
ActiveMq persistence related configuration: /usr/local/apache-activemq-5.11.1/conf/activemq.xml
The following is the configuration of modifying activemq, the specific usage scenario, waiting for the demo, in the test
The official default persistence is Kahadb:
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"
</persistenceAdapter>
Can be slightly tuned: If you do not want to use database persistence, use the following methods to optimize the following persistent message information
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"
indexWriteBatchSize="1000"
journalMaxFileLength="32mb"
enableIndexWriteAsync="true"
enableJournalDiskSyncs="false"/>
</persistenceAdapter>
Example showing persistence using mysql:
Modify the persistenceAdapter node:
<persistenceAdapter>
<jdbcPersistenceAdapter directory="${activemq.data}/mysqldb" dataSource="#ds-mysql"/>
</persistenceAdapter>
Add mysql related configuration information before the <import resource="jetty.xml"/> node
<bean id="ds-mysql" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://192.168.1.202:3306/activemq?relaxAutoCommit=true"/>
<property name="username" value="root"/>
<property name="password" value="fxtx1105"/>
<property name="maxActive" value="200"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
Add dependent druid and mysql driver packages to lib
Create the activemq database and restart Activemq, you can see that three tables have been added to the activemq library
The persistent record will be deleted after the message is consumed.
It is said on the Internet that the performance of persistence is not good, and the message consumption is easy to be locked. I hope to get good opinions and suggestions, I am testing