Active MQ – Configure with MySQL

http://barkingiguana.com/2008/12/16/high-availability-activemq-using-a-mysql-datastore

You’ll need to create an activemq configuration file, call it my-activemq.xml say. (Just copy ./conf/activemq.xml and modify it as described here.
Uncomment & update the persistenceAdapter:


<persistenceAdapter>

<journaledJDBC journalLogFiles="5" dataDirectory="${activemq.base}/activemq-data" dataSource="#mysql-ds"/>

</persistenceAdapter>

Uncomment the mysql-ds datasource (update the MySQL username/password):
<bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

<property name="driverClassName" value="com.mysql.jdbc.Driver"/>

<property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>

<property name="username" value="root"/> <property name="password" value=""/>

<property name="poolPreparedStatements" value="true"/>

</bean>

Get the MySQL Java Connector (aka the driver). Add the connector jar file
mysql-connector-java-5.0.6-bin.jar
to the activemq’s classpath (just copy this jar to the activemq’s lib/optional folder. Launch the MySQL command line program and create a database for ActiveMQ to use: create database activemq;
You can now start the broker using the xbean option:
./bin/activemq xbean:./conf/my-activemq.xml
The broker (aka JMS server) should start without a problem. You can verify that it using the database. Check the activemq database and you’ll see that 3 new tables have been created:
mysql> use activemq; show tables;Database changed

+——————–+

| Tables_in_activemq |

+——————–+

| ACTIVEMQ_ACKS |

| ACTIVEMQ_LOCK |

| activemq_msgs |

+——————–+

3 rows in set (0.00 sec)

Also visit the ActiveMQ’s admin console on http://localhost:8161/ to make sure that all is well.