LibraryLink ToToggle FramesPrintFeedback

Using JDBC with the High Performance Journal

Using the JDBC persistence adapter with ActiveMQ's high performance journal boosts the performance of the persistence adapter in two ways:

In addition to the performance gains, the high performance journal also makes it possible to ensure the consistency of JMS transactions in the case of a system failure.

Example 3.3 shows a configuration fragment that configures the journaled JDBC adapter to use a MySQL database.

Example 3.3. Configuring ActiveMQ to use the Journaled JDBC Persistence Adapter

<beans ...>
  <broker ...>
1  <persistenceFactory>
2    <journaledJDBC journalLogFiles="5" dataSource="#mysql-ds" />
3<bean id="mysql-ds"
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>
    <property name="username" value="activemq"/>
    <property name="password" value="activemq"/>
    <property name="poolPreparedStatements" value="true"/>

The configuration in Example 3.3 has three noteworthy elements:


The persistenceFactory element wraps the configuration for the JDBC persistence adapter.


In ActiveMQ versions prior to 5.4, the persistenceAdapter element was sometimes used to wrap the configuration for the JDBC persistence adapter. This is no longer possible in 5.4, because the broker performs strict schema checking on the configuration file.


The journaledJDBC element specifies that the broker will use the JDBC persistence adapter with the high performance journal. The element's attributes configure the following properties:

  • The journal will span five log files.

  • The configuration for the JDBC driver is specified in a bean element with the ID, mysql-ds.


The bean element specified the configuration for the MySQL JDBC driver.

Table 3.1 describes the attributes used to configure the journaled JDBC persistence adapter.