JMS message persistence: Persistence of ActiveMQ messages to mySql database ActiveMQ5.8.0 uses kahadb as the default message persistence mode. By using the default persistence mechanism, we cannot directly see how the message persists. The JDBC persistence mechanism provided by ActiveMQ can store persistent information to the database. By viewing the table structure and stored data generated by ActiveMQ in the database, we can better understand the message persistence mechanism. Now we will introduce how to configure activemq to persistently store data in mysql.
1. configure the mySql data source required by activeMQ
To access the mysql database using JDBC, you must configure the database source of the message server. Configure in activemq/apache-activemq-5.8.0/conf/activemq. xml
InAdd the data source configuration after the node
2. change the default persistence mode of activeMQ.
Comment out the default kahadb in activemq. xml and use jdbc persistence.
3. provide mysql drivers
Because of the activeMQ message server, there is no built-in mysql database driver. We need to manually add the mysql driver to the message server.
The method is to copy the driver to the apache-activemq-5.8.0/lib/directory.
After completing the preceding three steps, we can restart the message server and find that activeMQ creates three tables in the database.
Activemq_acks, activemq_lock, and activemq_msgs. So far, the database persistence is complete. I will continue to introduce the meanings and usage of these three tables in my blog later.