Fuse Message Broker provides options to customize the interaction between the JDBC persistence adapter and the underlying database. In some cases you might be able to use these customization options to integrate the JDBC persistence adapter with an unsupported database.
You can customize the SQL statements that the JDBC persistence adapter uses to
access the database. This is done by adding a statements
element to the
JDBC persistence adapter configuration. Example 3.5 shows a configuration snippet that
specifies that long strings are going to be stored as
VARCHAR(128).
Example 3.5. Fine Tuning the Database Schema
<persistenceFactory> <journaledJDBC ... > <statements> <statements stringIdDataType ="VARCHAR(128)"/> </statements> </journaledJDBC> </persistenceFactory>
The first statements
element is a wrapper for one or more
nested statements
elements. Each nested statements
element
specifies a single configuration statement. Table 3.3 describes the configurable
properties.
Table 3.3. Statements for Configuring the SQL Statements Used by the JDBC Persistence Adapter
The properties listed in Table 3.3 configure the default SQL statements used by the JDBC adapter and work with all of the supported databases.
If you need to override the default statements to work with an unsupported database, there are a number of other properties that can be set. These include:
addMessageStatement
updateMessageStatement
removeMessageStatement
findMessageSequenceIdStatement
findMessageStatement
findAllMessagesStatement
findLastSequenceIdInMsgsStatement
findLastSequenceIdInAcksStatement
createDurableSubStatement
findDurableSubStatement
findAllDurableSubsStatement
updateLastAckOfDurableSubStatement
deleteSubscriptionStatement
findAllDurableSubMessagesStatement
findDurableSubMessagesStatement
findAllDestinationsStatement
removeAllMessagesStatement
removeAllSubscriptionsStatement
deleteOldMessagesStatement
lockCreateStatement
lockUpdateStatement
nextDurableSubscriberMessageStatement
durableSubscriberMessageCountStatement
lastAckedDurableSubscriberMessageStatement
destinationMessageCountStatement
findNextMessageStatement
createSchemaStatements
dropSchemaStatements
To use a JDBC provider not natively supported by Fuse Message Broker, you can configure the JDBC
persistence adapter, by setting the persistence adapter's adapter
attribute to reference the bean ID of the relevant adapter. The following adapter
types are supported:
org.activemq.store.jdbc.adapter.BlobJDBCAdapter
org.activemq.store.jdbc.adapter.BytesJDBCAdapter
org.activemq.store.jdbc.adapter.DefaultJDBCAdapter
org.activemq.store.jdbc.adapter.ImageJDBCAdapter
Various settings are provided to customize how the JDBC adapter stores and accesses BLOB fields in the database. To determine the proper settings, consult the documentation for your JDBC driver and your database.
Example 3.6 shows a configuration snippet configuring the journaled JDBC persistence adapter to use the blob JDBC adapter.
Example 3.6. Configuring a Generic JDBC Provider
<broker persistent="true" ... > ... <persistenceFactory> <journaledJDBC adapter="#blobAdapter" ... /> </persistenceFactory> <bean id="blobAdapter" class="org.activemq.store.jdbc.adapter.BlobJDBCAdapter"/> ... </broker>