Using the ActiveMQ journal with a JDBC Store
In this tutorial we have described how to configure the JDBC Store with ActiveMQ: Using a JDBC Store for ArtemisMQ. We will see now how we can improve the performance of it by using the ActiveMQ journal.
Using the ActiveMQ journal can improve the performance of the JDBC store as messages can be stored locally on the filesystem before being committed to the database. On the other hand, it cannot be used on a Master-Slave scenario as there is no guarantee that messages are exactly replicated if one of the Broker fails.
Here is the configuration of the Journal, which uses the MySQL JDBC datasource:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
. . .
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
<destinationPolicy>
. . . .
</destinationPolicy>
<managementContext>
. . .
</managementContext>
<persistenceAdapter>
<jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#mysql-ds" />
</persistenceAdapter>
<systemUsage>
. . . .
</systemUsage>
<transportConnectors>
. . .
</transportConnectors>
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
</shutdownHooks>
<persistenceFactory>
<journalPersistenceAdapterFactory
journalLogFiles="4"
journalLogFileSize="32768"
useJournal="true"
useQuickJournal="true"
dataSource="#mysql-ds"
dataDirectory="activemq-data" />
</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="francesco" />
<property name="password" value="francesco" />
<property name="maxActive" value="200" />
<property name="poolPreparedStatements" value="true" />
</bean>
<import resource="jetty.xml" />
</beans>
Recommended Articles
Install and Configure WildFly Datasource with MySQL or MariaDB Using Docker
Learn how to install and configure a WildFly datasource using MySQL or MariaDB, including setting up MySQL in Docker.
Configure WildFly 11 for JMS JDBC Persistence Store using MySQL - Step-by-Step Guide
Learn how to set up a WildFly 11 server with JMS JDBC Store persistence using MySQL. Follow this tutorial to configure WildFly, create a datasource, and deploy a JMS quickstart.
Configure WildFly 11 Elytron JDBC Realm with MySQL Database - Step-by-Step Guide
Learn how to configure an Elytron JDBC Realm on WildFly 11 using both Web Console and CLI. Prerequisites: MySQL Database, WildFly 11 or newer.
Configure Agroal Datasource on WildFly 14 for Enhanced Performance and Security
Learn how to configure Agroal Datasource on WildFly 14 for improved performance, security, and scalability in this step-by-step guide.