LibraryLink ToToggle FramesPrintFeedback

Using JDBC without the Journal

For those cases where journaling is not appropriate, or you wish to use your own journaling system, you can used the JDBC persistence adapter without the ActiveMQ high performance journal.

Example 3.4 shows a configuration fragment that configures the plain JDBC adapter to use the Apache Derby database.

Example 3.4. Configuring ActiveMQ to use the Plain JDBC Persistence Adapter

<beans ...>
  <broker ...>
1  <persistenceAdapter>
2    <jdbcPersistenceAdapter dataSource="#derby-ds" />
3<bean id="derby-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
    <property name="databaseName" value="derbydb"/>
    <property name="createDatabase" value="create"/>

The configuration in Example 3.4 has three noteworthy elements:


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


The jdbcPersistenceAdapter element specifies that the broker will use the plain JDBC persistence adapter and that the JDBC driver's configuration is specified in a bean element with the ID, derby-ds.


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

Table 3.2 describes the attributes used to configure the non-journaled JDBC persistence adapter.

Table 3.2. Attributes for Configuring the Plain JDBC Persistence Adapter

AttributeDefault ValueDescription
adapter  Specifies the strategy to use when accessing a non-supported database. For more information see Using generic JDBC providers.
cleanupPeriod 300000Specifies, in milliseconds, the interval at which acknowledged messages are deleted.
createTablesOnStartup trueSpecifies whether or not new database tables are created when the broker starts. If the database tables already exist, the existing tables are reused.
databaseLockerDefaultDatabaseLocker instanceThe locker instance that prevents more than one broker from accessing the database at a time.
dataDirectory activemq-dataSpecifies the directory into which the default Derby database writes its files.
dataSource #derbySpecifies the id of the Spring bean storing the JDBC driver's configuration. For more information see Configuring your JDBC driver.
lockAcquireSleepInterval1000Time interval (ms) between lock acquire attempts, when using the default database locker. Does not apply to custom database lockers, specified using databaseLocker.
lockKeepAlivePeriod30000Periodically save the current time in the locker table, at time intervals specified by this option (ms). This ensure that the lock does not time out.
useDatabaseLock trueSpecifies whether or not an exclusive database lock should be used to enable JDBC Master/Slave—see JDBC Master/Slave in Clustering Guide.
transactionIsolationConnection.TRANSACTION_READ_UNCOMMITTEDSpecifies the required transaction isolation level. For allowed values, see java.sql.Connection.