In this blog I will show you how to change, the default persistence mechanism in Apache ActiveMQ 5.8.0 from KahaDB to instead use a RDBMS. And here I will use MySQL 5, but ActiveMQ supports most of the major vendor of RDBMS.
Install MySQL JDBC Driver
Download driver from maven central repo:
Copy to $ACTIVEMQ_HOME/lib/optional/.
Create ActiveMQ database
Log into mysql and create ActiveMQ database.
Configure MySQL as persistence storage
Open the ActiveMQ configuration, $ACTIVEMQ_HOME/conf/activemq.xml, and add mysql datasource, comment/remove the default KahaDB and finally add the RDBMS persistence adapter.
Now we are ready to test the installation. Restart activemq and check the activemq log for errors, $ACTIVEMQ_HOME/data/activemq.log.
You can also open the activemq web console, to verify that things are working:
Now lets really test the installation from the activemq web console you can send message. From the web console click Send and choose to send a text message to a new queue.
Afterwards we can check that the message is sent to the queue, by clicking on Queue and our new queue foo.bar. And there see your text message.
You could also verify that the message is really persistent in MySQL by querying your database.