Using the JDBC persistence adapter with Fuse Message Broker's high performance journal boosts the performance of the persistence adapter in two ways:
In applications where message consumers keep up with the message producers, the journal makes it possible to lower the number of messages that need to be committed to the data base. For example a message producer could publish 10,000 messages between journal checkpoints. If the message consumer pops 9,900 messages off of the queue during the same interval, only 100 messages will be committed to the database through the JDBC adapter.
In applications where the message consumers cannot keep up with the message producers, or in applications where messages must persist for long periods, the journal boosts performance by committing messages in large batches. This means that the JDBC driver can optimize the writes to the external database.
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 Fuse Message Broker to use the Journaled JDBC Persistence Adapter
<beans ... > <broker ...> ... <persistenceFactory> <journaledJDBC journalLogFiles="5" dataSource="#mysql-ds" /> </persistenceFactory> ... <broker> ... <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="activemq"/> <property name="password" value="activemq"/> <property name="poolPreparedStatements" value="true"/> </bean>
The configuration in Example 3.3 has three noteworthy elements:
The
| ||||
The
| ||||
The |
Table 3.1 describes the attributes used to configure the journaled JDBC persistence adapter.
Table 3.1. Attributes for Configuring the Journaled JDBC Persistence Adapter
Attribute | Default Value | Description |
---|---|---|
adapter
| Specifies the strategy to use when accessing a non-supported database. For more information see Using generic JDBC providers. | |
createTablesOnStartup
| true | Specifies whether or not new database tables are created when the broker starts. If the database tables already exist, the existing tables are reused. |
dataDirectory
| activemq-data | Specifies the directory into which the default Derby database writes its files. |
dataSource
| #derby | Specifies the id of the Spring bean storing the JDBC driver's configuration. For more information see Configuring your JDBC driver. |
journalArchiveDirectory
| Specifies the directory used to store archived journal log files. | |
journalLogFiles
| 2 | Specifies the number of log files to use for storing the journal. |
journalLogFileSize
| 20MB | Specifies the size for a journal's log file. |
journalThreadPriority
| 10 | Specifies the thread priority of the thread used for journaling. |
useDatabaseLock
| true | Specifies whether or not an exclusive database lock should be used to enable JDBC Master/Slave. |
useJournal
| true | Specifies whether or not to use the journal. |