<p>In this tutorial we have described how to configure the <strong>JDBC</strong> Store with <strong>ActiveMQ</strong>: <a href="/jboss-frameworks/apache-activemq?amp;view=article&amp;id=708&amp;catid=242&amp;Itemid=422">Using a JDBC Store with ActiveMQ</a> . We will see now how we can improve the performance of it by using the <strong>ActiveMQ journal</strong>.</p>
<hr id="system-readmore" />
<p>Using the <strong>ActiveMQ</strong> 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.</p>
<p>Here is the configuration of the Journal, which uses the MySQL JDBC datasource:</p>
<pre class="brush:xml; highlight: [13,14,15,28,29,30,31,32,33,34,35,36,37,38.39,40,41,42,43,44,45]">&lt;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"&gt;
 
       . . .
 
   &lt;broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}"&gt;
      &lt;destinationPolicy&gt;
        . . . .
      &lt;/destinationPolicy&gt;
      &lt;managementContext&gt;
         . . .
      &lt;/managementContext&gt;
 
      &lt;persistenceAdapter&gt;
         &lt;jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#mysql-ds" /&gt;
      &lt;/persistenceAdapter&gt;
 
      &lt;systemUsage&gt;
        . . . .
      &lt;/systemUsage&gt;
      &lt;transportConnectors&gt;
         . . .
         
      &lt;/transportConnectors&gt;
 
      &lt;shutdownHooks&gt;
         &lt;bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" /&gt;
      &lt;/shutdownHooks&gt;
    &lt;persistenceFactory&gt;      
      &lt;journalPersistenceAdapterFactory
        journalLogFiles="4"
        journalLogFileSize="32768"
        useJournal="true"
        useQuickJournal="true"
        dataSource="#mysql-ds"
        dataDirectory="activemq-data" /&gt;
    &lt;/persistenceFactory&gt;
   &lt;/broker&gt;
   &lt;bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true" /&gt;
      &lt;property name="username" value="francesco" /&gt;
      &lt;property name="password" value="francesco" /&gt;
      &lt;property name="maxActive" value="200" /&gt;
      &lt;property name="poolPreparedStatements" value="true" /&gt;
   &lt;/bean&gt;
   &lt;import resource="jetty.xml" /&gt;
&lt;/beans&gt;</pre>
<p> </p>

0
0
0
s2smodern

W

i

l

d

F

l

y

 

c

h

e

a

t

s

h

e

e

t