activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [4/8] activemq-artemis git commit: ARTEMIS-27 / ARTEMIS-340 Add JDBC Storage Manager
Date Wed, 13 Jan 2016 14:49:43 GMT
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationStartSyncMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationStartSyncMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationStartSyncMessage.java
index 56c9461..d31db8b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationStartSyncMessage.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationStartSyncMessage.java
@@ -22,7 +22,7 @@ import java.util.List;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.core.journal.impl.JournalFile;
-import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager.JournalContent;
+import org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 
 /**
@@ -40,8 +40,8 @@ public class ReplicationStartSyncMessage extends PacketImpl {
    private boolean allowsAutoFailBack;
 
    public enum SyncDataType {
-      JournalBindings(JournalContent.BINDINGS.typeByte),
-      JournalMessages(JournalContent.MESSAGES.typeByte),
+      JournalBindings(AbstractJournalStorageManager.JournalContent.BINDINGS.typeByte),
+      JournalMessages(AbstractJournalStorageManager.JournalContent.MESSAGES.typeByte),
       LargeMessages((byte) 2);
 
       private byte code;
@@ -50,8 +50,8 @@ public class ReplicationStartSyncMessage extends PacketImpl {
          this.code = code;
       }
 
-      public static JournalContent getJournalContentType(SyncDataType dataType) {
-         return JournalContent.getType(dataType.code);
+      public static AbstractJournalStorageManager.JournalContent getJournalContentType(SyncDataType dataType) {
+         return AbstractJournalStorageManager.JournalContent.getType(dataType.code);
       }
 
       public static SyncDataType getDataType(byte code) {
@@ -86,7 +86,7 @@ public class ReplicationStartSyncMessage extends PacketImpl {
    }
 
    public ReplicationStartSyncMessage(JournalFile[] datafiles,
-                                      JournalContent contentType,
+                                      AbstractJournalStorageManager.JournalContent contentType,
                                       String nodeID,
                                       boolean allowsAutoFailBack) {
       this();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java
index 6c3007c..ed5901f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java
@@ -23,7 +23,7 @@ import java.util.Set;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager.JournalContent;
+import org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 
 /**
@@ -35,7 +35,7 @@ public final class ReplicationSyncFileMessage extends PacketImpl {
    /**
     * The JournalType or {@code null} if sync'ing large-messages.
     */
-   private JournalContent journalType;
+   private AbstractJournalStorageManager.JournalContent journalType;
    /**
     * This value refers to {@link org.apache.activemq.artemis.core.journal.impl.JournalFile#getFileID()}, or the
     * message id if we are sync'ing a large-message.
@@ -74,7 +74,7 @@ public final class ReplicationSyncFileMessage extends PacketImpl {
       super(REPLICATION_SYNC_FILE);
    }
 
-   public ReplicationSyncFileMessage(JournalContent content,
+   public ReplicationSyncFileMessage(AbstractJournalStorageManager.JournalContent content,
                                      SimpleString storeName,
                                      long id,
                                      int size,
@@ -135,7 +135,7 @@ public final class ReplicationSyncFileMessage extends PacketImpl {
       fileId = buffer.readLong();
       switch (FileType.getFileType(buffer.readByte())) {
          case JOURNAL: {
-            journalType = JournalContent.getType(buffer.readByte());
+            journalType = AbstractJournalStorageManager.JournalContent.getType(buffer.readByte());
             fileType = FileType.JOURNAL;
             break;
          }
@@ -160,7 +160,7 @@ public final class ReplicationSyncFileMessage extends PacketImpl {
       return fileId;
    }
 
-   public JournalContent getJournalContent() {
+   public AbstractJournalStorageManager.JournalContent getJournalContent() {
       return journalType;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java
index 63e3935..5b6dbfb 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java
@@ -47,7 +47,7 @@ import org.apache.activemq.artemis.core.paging.impl.Page;
 import org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl;
 import org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
-import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager.JournalContent;
+import org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager.JournalContent;
 import org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageInSync;
 import org.apache.activemq.artemis.core.protocol.core.Channel;
 import org.apache.activemq.artemis.core.protocol.core.ChannelHandler;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
index 255415b..a8984fc 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
@@ -32,12 +32,12 @@ import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.SessionFailureListener;
-import org.apache.activemq.artemis.core.journal.EncodingSupport;
 import org.apache.activemq.artemis.core.io.SequentialFile;
+import org.apache.activemq.artemis.core.journal.EncodingSupport;
 import org.apache.activemq.artemis.core.journal.impl.JournalFile;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.persistence.OperationContext;
-import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager.JournalContent;
+import org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
 import org.apache.activemq.artemis.core.protocol.core.Channel;
 import org.apache.activemq.artemis.core.protocol.core.ChannelHandler;
@@ -437,7 +437,7 @@ public final class ReplicationManager implements ActiveMQComponent {
     * @throws ActiveMQException
     * @throws Exception
     */
-   public void syncJournalFile(JournalFile jf, JournalContent content) throws Exception {
+   public void syncJournalFile(JournalFile jf, AbstractJournalStorageManager.JournalContent content) throws Exception {
       if (!enabled) {
          return;
       }
@@ -473,7 +473,7 @@ public final class ReplicationManager implements ActiveMQComponent {
     * @param maxBytesToSend maximum number of bytes to read and send from the file
     * @throws Exception
     */
-   private void sendLargeFile(JournalContent content,
+   private void sendLargeFile(AbstractJournalStorageManager.JournalContent content,
                               SimpleString pageStore,
                               final long id,
                               SequentialFile file,
@@ -536,7 +536,7 @@ public final class ReplicationManager implements ActiveMQComponent {
     * @throws ActiveMQException
     */
    public void sendStartSyncMessage(JournalFile[] datafiles,
-                                    JournalContent contentType,
+                                    AbstractJournalStorageManager.JournalContent contentType,
                                     String nodeID,
                                     boolean allowsAutoFailBack) throws ActiveMQException {
       if (enabled)

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/SecurityAuth.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/SecurityAuth.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/SecurityAuth.java
index e7d4bb2..0cdb77d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/SecurityAuth.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/SecurityAuth.java
@@ -6,7 +6,7 @@
  * (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index ae93a97..58993fc 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -51,6 +51,7 @@ import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.config.ConfigurationUtils;
 import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
 import org.apache.activemq.artemis.core.config.DivertConfiguration;
+import org.apache.activemq.artemis.core.config.StoreConfiguration;
 import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.filter.impl.FilterImpl;
@@ -70,6 +71,7 @@ import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting;
 import org.apache.activemq.artemis.core.persistence.config.PersistedRoles;
 import org.apache.activemq.artemis.core.persistence.impl.PageCountPending;
+import org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
 import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
@@ -1479,7 +1481,13 @@ public class ActiveMQServerImpl implements ActiveMQServer {
     */
    private StorageManager createStorageManager() {
       if (configuration.isPersistenceEnabled()) {
-         return new JournalStorageManager(configuration, executorFactory, shutdownOnCriticalIO);
+         if (configuration.getStoreConfiguration() != null && configuration.getStoreConfiguration().getStoreType() == StoreConfiguration.StoreType.DATABASE) {
+            return new JDBCJournalStorageManager(configuration, executorFactory, shutdownOnCriticalIO);
+         }
+         // Default to File Based Storage Manager, (Legacy default configuration).
+         else {
+            return new JournalStorageManager(configuration, executorFactory, shutdownOnCriticalIO);
+         }
       }
       return new NullStorageManager();
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/artemis-server/src/main/resources/schema/artemis-configuration.xsd
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/resources/schema/artemis-configuration.xsd b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
index 59b0491..9174019 100644
--- a/artemis-server/src/main/resources/schema/artemis-configuration.xsd
+++ b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
@@ -683,6 +683,14 @@
             </xsd:annotation>
          </xsd:element>
 
+         <xsd:element name="store" type="storeType" maxOccurs="1" minOccurs="0">
+            <xsd:annotation>
+               <xsd:documentation>
+                  The Store Type used by the server
+               </xsd:documentation>
+            </xsd:annotation>
+         </xsd:element>
+
          <xsd:element name="security-settings" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
@@ -1437,6 +1445,55 @@
       </xsd:attribute>
 
    </xsd:complexType>
+
+   <xsd:complexType name="storeType">
+      <xsd:choice>
+         <xsd:element name="file-store" type="fileStoreType" minOccurs="0" maxOccurs="1">
+            <xsd:annotation>
+               <xsd:documentation>
+                  Use a file based store for peristing journal, paging and large messages
+               </xsd:documentation>
+            </xsd:annotation>
+         </xsd:element>
+         <xsd:element name="database-store" type="databaseStoreType" minOccurs="0" maxOccurs="1">
+            <xsd:annotation>
+               <xsd:documentation>
+                  Use a database for persisting journal, paging and large messages
+               </xsd:documentation>
+            </xsd:annotation>
+         </xsd:element>
+      </xsd:choice>
+   </xsd:complexType>
+
+   <xsd:complexType name="fileStoreType">
+   </xsd:complexType>
+
+   <xsd:complexType name="databaseStoreType">
+      <xsd:all>
+         <xsd:element name="jdbc-connection-url" type="xsd:string" minOccurs="1" maxOccurs="1">
+            <xsd:annotation>
+               <xsd:documentation>
+                  The JDBC Connection URL e.g. jdbc:mysql://localhost:3306/
+               </xsd:documentation>
+            </xsd:annotation>
+         </xsd:element>
+         <xsd:element name="message-table-name" type="xsd:string" minOccurs="1" maxOccurs="1">
+            <xsd:annotation>
+               <xsd:documentation>
+                  The table name used to store message journal entries
+               </xsd:documentation>
+            </xsd:annotation>
+         </xsd:element>
+         <xsd:element name="bindings-table-name" type="xsd:string" minOccurs="1" maxOccurs="1">
+            <xsd:annotation>
+               <xsd:documentation>
+                  The table name used to store bindings journal entries
+               </xsd:documentation>
+            </xsd:annotation>
+         </xsd:element>
+      </xsd:all>
+   </xsd:complexType>
+
    <xsd:complexType name="haPolicyType">
       <xsd:choice>
          <xsd:element name="live-only" type="haLiveOnlyPolicyType" minOccurs="0" maxOccurs="1">
@@ -1489,6 +1546,7 @@
       </xsd:choice>
    </xsd:complexType>
 
+
    <xsd:complexType name="haColocationReplicationType">
       <xsd:all>
          <xsd:element name="request-backup" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false">

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DatabaseStoreConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DatabaseStoreConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DatabaseStoreConfigurationTest.java
new file mode 100644
index 0000000..4934cbd
--- /dev/null
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DatabaseStoreConfigurationTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.core.config.impl;
+
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.FileDeploymentManager;
+import org.apache.activemq.artemis.core.config.StoreConfiguration;
+import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.junit.Test;
+
+public class DatabaseStoreConfigurationTest extends ActiveMQTestBase {
+
+   @Test
+   public void databaseStoreConfigTest() throws Exception {
+      Configuration configuration = createConfiguration("database-store-config.xml");
+      ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
+      assertEquals(StoreConfiguration.StoreType.DATABASE, server.getConfiguration().getStoreConfiguration().getStoreType());
+   }
+
+   protected Configuration createConfiguration(String fileName) throws Exception {
+      FileConfiguration fc = new FileConfiguration();
+      FileDeploymentManager deploymentManager = new FileDeploymentManager(fileName);
+      deploymentManager.addDeployable(fc);
+
+      deploymentManager.readConfiguration();
+
+      // we need this otherwise the data folder will be located under activemq-server and not on the temporary directory
+      fc.setPagingDirectory(getTestDir() + "/" + fc.getPagingDirectory());
+      fc.setLargeMessagesDirectory(getTestDir() + "/" + fc.getLargeMessagesDirectory());
+      fc.setJournalDirectory(getTestDir() + "/" + fc.getJournalDirectory());
+      fc.setBindingsDirectory(getTestDir() + "/" + fc.getBindingsDirectory());
+
+      return fc;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
index bd2a156..5d76df8 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
@@ -80,6 +80,7 @@ import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
 import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
+import org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration;
 import org.apache.activemq.artemis.core.io.SequentialFileFactory;
 import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
 import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
@@ -387,6 +388,19 @@ public abstract class ActiveMQTestBase extends Assert {
       return createDefaultConfig(0, netty);
    }
 
+   protected Configuration createDefaultJDBCConfig() throws Exception {
+      Configuration configuration = createDefaultConfig(true);
+
+      DatabaseStorageConfiguration dbStorageConfiguration = new DatabaseStorageConfiguration();
+      dbStorageConfiguration.setJdbcConnectionUrl(getTestJDBCConnectionUrl());
+      dbStorageConfiguration.setBindingsTableName("BINDINGS");
+      dbStorageConfiguration.setMessageTableName("MESSAGES");
+
+      configuration.setStoreConfiguration(dbStorageConfiguration);
+
+      return configuration;
+   }
+
    protected Configuration createDefaultConfig(final int serverID, final boolean netty) throws Exception {
       ConfigurationImpl configuration = createBasicConfig(serverID).setJMXManagementEnabled(false).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, generateInVMParams(serverID)));
 
@@ -749,6 +763,10 @@ public abstract class ActiveMQTestBase extends Assert {
       return testDir;
    }
 
+   protected final String getTestJDBCConnectionUrl() {
+      return "jdbc:derby:" + getTestDir() + File.separator + "derby;create=true";
+   }
+
    protected final File getTestDirfile() {
       return new File(testDir);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/artemis-server/src/test/resources/database-store-config.xml
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/resources/database-store-config.xml b/artemis-server/src/test/resources/database-store-config.xml
new file mode 100644
index 0000000..e387c2c
--- /dev/null
+++ b/artemis-server/src/test/resources/database-store-config.xml
@@ -0,0 +1,30 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<configuration
+      xmlns="urn:activemq"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="urn:activemq ../../main/resources/schema/artemis-server.xsd">
+   <core xmlns="urn:activemq:core">
+      <store>
+         <database-store>
+            <jdbc-connection-url>jdbc:derby:target/derby/database-store;create=true</jdbc-connection-url>
+            <bindings-table-name>BINDINGS_TABLE</bindings-table-name>
+            <message-table-name>MESSAGE_TABLE</message-table-name>
+         </database-store>
+      </store>
+   </core>
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/docs/user-manual/en/persistence.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/persistence.md b/docs/user-manual/en/persistence.md
index ccf14ec..e5bcf81 100644
--- a/docs/user-manual/en/persistence.md
+++ b/docs/user-manual/en/persistence.md
@@ -3,12 +3,14 @@
 In this chapter we will describe how persistence works with Apache ActiveMQ Artemis and
 how to configure it.
 
-Apache ActiveMQ Artemis ships with a high performance journal. Since Apache ActiveMQ Artemis handles
-its own persistence, rather than relying on a database or other 3rd
-party persistence engine it is very highly optimised for the specific
-messaging use cases.
+Apache ActiveMQ Artemis ships with two persistence options.  The Apache ActiveMQ Artemis File journal
+which is highly optimized for the messaging use case and gives great performance, and also Apache Artemis
+JDBC Store, which uses JDBC to connect to a database of your choice.  The JDBC Store is still under development,
+but it is possible to use it's journal features, (essentially everything except for paging and large messages).
 
-An Apache ActiveMQ Artemis journal is an *append only* journal. It consists of a set of
+## Apache ActiveMQ Artemis File Journal (Default)
+
+An Apache ActiveMQ Artemis file journal is an *append only* journal. It consists of a set of
 files on disk. Each file is pre-created to a fixed size and initially
 filled with padding. As operations are performed on the server, e.g. add
 message, update message, delete message, records are appended to the
@@ -126,7 +128,7 @@ If no persistence is required at all, Apache ActiveMQ Artemis can also be config
 not to persist any data at all to storage as discussed in the Configuring
 the broker for Zero Persistence section.
 
-## Configuring the bindings journal
+### Configuring the bindings journal
 
 The bindings journal is configured using the following attributes in
 `broker.xml`
@@ -143,11 +145,11 @@ The bindings journal is configured using the following attributes in
     `bindings-directory` if it does not already exist. The default value
     is `true`
 
-## Configuring the jms journal
+### Configuring the jms journal
 
 The jms config shares its configuration with the bindings journal.
 
-## Configuring the message journal
+### Configuring the message journal
 
 The message journal is configured using the following attributes in
 `broker.xml`
@@ -297,7 +299,7 @@ The message journal is configured using the following attributes in
 
     The default for this parameter is `30`
 
-## An important note on disabling disk write cache.
+### An important note on disabling disk write cache.
 
 > **Warning**
 >
@@ -336,7 +338,7 @@ The message journal is configured using the following attributes in
 > On Windows you can check / change the setting by right clicking on the
 > disk and clicking properties.
 
-## Installing AIO
+### Installing AIO
 
 The Java NIO journal gives great performance, but If you are running
 Apache ActiveMQ Artemis using Linux Kernel 2.6 or later, we highly recommend you use
@@ -356,6 +358,40 @@ Using aptitude, (e.g. on Ubuntu or Debian system):
 
     apt-get install libaio
 
+## Apache ActiveMQ Artemis JDBC Persistence
+
+The Apache ActiveMQ Artemis JDBC persistence store is still under development and only supports persistence of standard messages and bindings (this is everything except large messages and paging).  The JDBC store uses a JDBC connection to store messages and bindings data in records in database tables.  The data stored in the database tables is encoded using Apache ActiveMQ Artemis journal encoding.
+
+### Configuring JDBC Persistence
+
+To configure Apache ActiveMQ Artemis to use a database for persisting messages and bindings data you must do two things.
+
+1. Add the appropriate JDBC client libraries to the Artemis runtime.  You can do this by dropping the relevant jars in the lib folder of the ActiveMQ Artemis distribution.
+
+2. create a store element in your broker.xml config file under the <core> element.  For example:
+
+```xml
+      <store>
+         <database-store>
+            <jdbc-connection-url>jdbc:derby:target/derby/database-store;create=true</jdbc-connection-url>
+            <bindings-table-name>BINDINGS_TABLE</bindings-table-name>
+            <message-table-name>MESSAGE_TABLE</message-table-name>
+         </database-store>
+      </store>
+```
+
+-   `jdbc-connection-url`
+
+    The full JDBC connection URL for your database server.  The connection url should include all configuration parameters and database name.
+    
+-   `bindings-table-name`
+
+    The name of the table in which bindings data will be persisted for the ActiveMQ Artemis server.  Specifying table names allows users to share single database amongst multiple servers, without interference.
+    
+-   `message-table-name`
+
+    The name of the table in which messages and related data will be persisted for the ActiveMQ Artemis server.  Specifying table names allows users to share single database amongst multiple servers, without interference.
+
 ## Configuring Apache ActiveMQ Artemis for Zero Persistence
 
 In some situations, zero persistence is sometimes required for a
@@ -366,3 +402,5 @@ straightforward. Simply set the parameter `persistence-enabled` in
 Please note that if you set this parameter to false, then *zero*
 persistence will occur. That means no bindings data, message data, large
 message data, duplicate id caches or paging data will be persisted.
+
+

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index fcbf91b..adfb650 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,7 @@
       <module>artemis-ra</module>
       <module>artemis-rest</module>
       <module>artemis-service-extensions</module>
+      <module>artemis-jdbc-store</module>
       <module>artemis-maven-plugin</module>
       <module>artemis-server-osgi</module>
       <module>integration/activemq-spring-integration</module>
@@ -82,6 +83,7 @@
       <resteasy.version>3.0.13.Final</resteasy.version>
       <proton.version>0.10</proton.version>
       <fuse.mqtt.client.version>1.10</fuse.mqtt.client.version>
+      <apache.derby.version>10.11.1.1</apache.derby.version>
       <skipUnitTests>true</skipUnitTests>
       <skipJmsTests>true</skipJmsTests>
       <skipExtraTests>true</skipExtraTests>
@@ -203,6 +205,11 @@
             <!-- Apache v2.0 License -->
          </dependency>
          <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>${apache.derby.version}</version>
+         </dependency>
+         <dependency>
             <groupId>org.eclipse.paho</groupId>
             <artifactId>mqtt-client</artifactId>
             <version>0.4.0</version>
@@ -588,10 +595,12 @@
             <module>artemis-native</module>
             <module>artemis-protocols</module>
             <module>artemis-journal</module>
+            <module>artemis-jdbc-store</module>
             <module>artemis-ra</module>
             <module>artemis-rest</module>
             <module>artemis-service-extensions</module>
             <module>artemis-maven-plugin</module>
+            <module>artemis-jdbc-store</module>
             <module>integration/activemq-spring-integration</module>
             <module>integration/activemq-aerogear-integration</module>
             <module>integration/activemq-vertx-integration</module>
@@ -623,6 +632,7 @@
             <module>artemis-jms-server</module>
             <module>artemis-native</module>
             <module>artemis-journal</module>
+            <module>artemis-jdbc-store</module>
             <module>artemis-ra</module>
             <module>artemis-rest</module>
             <module>artemis-service-extensions</module>
@@ -681,6 +691,7 @@
             <module>artemis-jms-server</module>
             <module>artemis-native</module>
             <module>artemis-journal</module>
+            <module>artemis-jdbc-store</module>
             <module>artemis-ra</module>
             <module>artemis-rest</module>
             <module>artemis-service-extensions</module>
@@ -723,6 +734,7 @@
             <module>artemis-jms-server</module>
             <module>artemis-native</module>
             <module>artemis-journal</module>
+            <module>artemis-jdbc-store</module>
             <module>artemis-ra</module>
             <module>artemis-rest</module>
             <module>artemis-service-extensions</module>
@@ -757,6 +769,7 @@
             <module>artemis-jms-server</module>
             <module>artemis-native</module>
             <module>artemis-journal</module>
+            <module>artemis-jdbc-store</module>
             <module>artemis-ra</module>
             <module>artemis-rest</module>
             <module>artemis-service-extensions</module>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index e33a3a2..adf8b47 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -119,6 +119,11 @@
       </dependency>
       <dependency>
          <groupId>org.apache.activemq</groupId>
+         <artifactId>artemis-jdbc-store</artifactId>
+         <version>${project.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>org.apache.activemq</groupId>
          <artifactId>artemis-amqp-protocol</artifactId>
          <version>${project.version}</version>
       </dependency>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingTest.java
index c8661b2..8680bda 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingTest.java
@@ -65,7 +65,7 @@ import org.apache.activemq.artemis.core.persistence.OperationContext;
 import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal;
 import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal.ReferenceDescribe;
 import org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds;
-import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager.AckDescribe;
+import org.apache.activemq.artemis.core.persistence.impl.journal.AckDescribe;
 import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.Queue;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/FakeEncodingSupportImpl.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/FakeEncodingSupportImpl.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/FakeEncodingSupportImpl.java
new file mode 100644
index 0000000..8068a42
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/FakeEncodingSupportImpl.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.jdbc.store.journal;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.core.journal.EncodingSupport;
+
+public class FakeEncodingSupportImpl implements EncodingSupport {
+
+   private byte[] data;
+
+   public FakeEncodingSupportImpl(byte[] data) {
+      this.data = data;
+   }
+
+   @Override
+   public int getEncodeSize() {
+      return data.length;
+   }
+
+   @Override
+   public void encode(ActiveMQBuffer buffer) {
+      buffer.writeBytes(data);
+   }
+
+   @Override
+   public void decode(ActiveMQBuffer buffer) {
+      data = new byte[buffer.readableBytes()];
+      buffer.readBytes(data);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/JDBCJournalTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/JDBCJournalTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/JDBCJournalTest.java
new file mode 100644
index 0000000..ed563ed
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/JDBCJournalTest.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.jdbc.store.journal;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.artemis.core.journal.IOCompletion;
+import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
+import org.apache.activemq.artemis.core.journal.RecordInfo;
+import org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class JDBCJournalTest {
+
+   private static final String JOURNAL_TABLE_NAME = "MESSAGE_JOURNAL";
+
+   private JDBCJournalImpl journal;
+
+   private String jdbcUrl;
+
+   private Properties jdbcConnectionProperties;
+
+   @Before
+   public void setup() throws Exception {
+      jdbcUrl = "jdbc:derby:target/data;create=true";
+      journal = new JDBCJournalImpl(jdbcUrl, JOURNAL_TABLE_NAME);
+      journal.start();
+   }
+
+   @Test
+   public void testInsertRecords() throws Exception {
+      int noRecords = 10;
+      for (int i = 0; i < noRecords; i++) {
+         journal.appendAddRecord(1, (byte) 1, new byte[0], true);
+      }
+
+      Thread.sleep(3000);
+      assertEquals(noRecords, journal.getNumberOfRecords());
+
+   }
+
+   @Test
+   public void testCallbacks() throws Exception {
+      final int noRecords = 10;
+      final CountDownLatch done = new CountDownLatch(noRecords);
+
+      IOCompletion completion = new IOCompletion() {
+         @Override
+         public void storeLineUp() {
+         }
+
+         @Override
+         public void done() {
+            done.countDown();
+         }
+
+         @Override
+         public void onError(int errorCode, String errorMessage) {
+
+         }
+      };
+
+      for (int i = 0; i < noRecords; i++) {
+         journal.appendAddRecord(1, (byte) 1, new FakeEncodingSupportImpl(new byte[0]), true, completion);
+      }
+      journal.sync();
+
+      done.await(5, TimeUnit.SECONDS);
+      assertEquals(done.getCount(), 0);
+   }
+
+   @Test
+   public void testReadJournal() throws Exception {
+      int noRecords = 100;
+
+      // Standard Add Records
+      for (int i = 0; i < noRecords; i++) {
+         journal.appendAddRecord(i, (byte) i, new byte[i], true);
+      }
+
+      // TX Records
+      int noTx = 10;
+      int noTxRecords = 100;
+      for (int i = 1000; i < 1000 + noTx; i++) {
+         for (int j = 0; j < noTxRecords; j++) {
+            journal.appendAddRecordTransactional(i, Long.valueOf(i + "" + j), (byte) 1, new byte[0]);
+         }
+         journal.appendPrepareRecord(i, new byte[0], true);
+         journal.appendCommitRecord(i, true);
+      }
+
+      Thread.sleep(2000);
+      List<RecordInfo> recordInfos = new ArrayList<>();
+      List<PreparedTransactionInfo> txInfos = new ArrayList<>();
+
+      journal.load(recordInfos, txInfos, null);
+
+      assertEquals(noRecords + (noTxRecords * noTx), recordInfos.size());
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      journal.destroy();
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/AddressSettingsConfigurationStorageTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/AddressSettingsConfigurationStorageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/AddressSettingsConfigurationStorageTest.java
index cca5ed4..c7d1920 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/AddressSettingsConfigurationStorageTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/AddressSettingsConfigurationStorageTest.java
@@ -16,22 +16,30 @@
  */
 package org.apache.activemq.artemis.tests.integration.persistence;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.StoreConfiguration;
+import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting;
-import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+@RunWith(Parameterized.class)
 public class AddressSettingsConfigurationStorageTest extends StorageManagerTestBase {
 
    private Map<SimpleString, PersistedAddressSetting> mapExpectedAddresses;
 
+   public AddressSettingsConfigurationStorageTest(StoreConfiguration.StoreType storeType) {
+      super(storeType);
+   }
+
    @Override
    @Before
    public void setUp() throws Exception {
@@ -40,7 +48,7 @@ public class AddressSettingsConfigurationStorageTest extends StorageManagerTestB
       mapExpectedAddresses = new HashMap<>();
    }
 
-   protected void addAddress(JournalStorageManager journal1, String address, AddressSettings setting) throws Exception {
+   protected void addAddress(StorageManager journal1, String address, AddressSettings setting) throws Exception {
       SimpleString str = new SimpleString(address);
       PersistedAddressSetting persistedSetting = new PersistedAddressSetting(str, setting);
       mapExpectedAddresses.put(str, persistedSetting);
@@ -84,7 +92,7 @@ public class AddressSettingsConfigurationStorageTest extends StorageManagerTestB
     * @param journal1
     * @throws Exception
     */
-   private void checkAddresses(JournalStorageManager journal1) throws Exception {
+   private void checkAddresses(StorageManager journal1) throws Exception {
       List<PersistedAddressSetting> listSetting = journal1.recoverAddressSettings();
 
       assertEquals(mapExpectedAddresses.size(), listSetting.size());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
index 8b783e9..de89e18 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
@@ -17,12 +17,13 @@
 package org.apache.activemq.artemis.tests.integration.persistence;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue;
-import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice;
 import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.StoreConfiguration;
 import org.apache.activemq.artemis.core.persistence.GroupingInfo;
 import org.apache.activemq.artemis.core.persistence.QueueBindingInfo;
 import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
@@ -30,8 +31,11 @@ import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.PostOfficeJournalLoader;
 import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue;
+import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice;
 import org.junit.Assert;
 import org.junit.Test;
+import org.junit.runners.Parameterized;
 
 public class DeleteMessagesOnStartupTest extends StorageManagerTestBase {
 
@@ -39,6 +43,17 @@ public class DeleteMessagesOnStartupTest extends StorageManagerTestBase {
 
    ArrayList<Long> deletedMessage = new ArrayList<>();
 
+   public DeleteMessagesOnStartupTest(StoreConfiguration.StoreType storeType) {
+      super(storeType);
+   }
+
+   // This is only applicable for FILE based store, as the database storage manager will automatically delete records.
+   @Parameterized.Parameters(name = "storeType")
+   public static Collection<Object[]> data() {
+      Object[][] params = new Object[][] {{StoreConfiguration.StoreType.FILE}};
+      return Arrays.asList(params);
+   }
+
    @Test
    public void testDeleteMessagesOnStartup() throws Exception {
       createStorage();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java
index 53faf54..38be202 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java
@@ -20,6 +20,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.StoreConfiguration;
 import org.apache.activemq.artemis.core.io.IOCallback;
 import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
 import org.apache.activemq.artemis.core.postoffice.DuplicateIDCache;
@@ -32,6 +33,10 @@ import org.junit.Test;
 
 public class DuplicateCacheTest extends StorageManagerTestBase {
 
+   public DuplicateCacheTest(StoreConfiguration.StoreType storeType) {
+      super(storeType);
+   }
+
    @After
    @Override
    public void tearDown() throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
index 88f67d3..fb8a3e7 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
@@ -19,6 +19,7 @@ package org.apache.activemq.artemis.tests.integration.persistence;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
 import org.apache.activemq.artemis.api.core.Pair;
+import org.apache.activemq.artemis.core.config.StoreConfiguration;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory;
 import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
@@ -36,6 +37,10 @@ public class JMSConnectionFactoryConfigurationStorageTest extends StorageManager
 
    private Map<String, PersistedConnectionFactory> mapExpectedCFs;
 
+   public JMSConnectionFactoryConfigurationStorageTest(StoreConfiguration.StoreType storeType) {
+      super(storeType);
+   }
+
    @Override
    @Before
    public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSStorageManagerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSStorageManagerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSStorageManagerTest.java
index 9dbe0ba..f67a190 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSStorageManagerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSStorageManagerTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.tests.integration.persistence;
 
+import org.apache.activemq.artemis.core.config.StoreConfiguration;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -27,6 +28,10 @@ import org.apache.activemq.artemis.jms.persistence.config.PersistedType;
 
 public class JMSStorageManagerTest extends StorageManagerTestBase {
 
+   public JMSStorageManagerTest(StoreConfiguration.StoreType storeType) {
+      super(storeType);
+   }
+
    //https://issues.jboss.org/browse/HORNETQ-812
    @Test
    public void testJNDIPersistence() throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java
index c0aaf86..391cccf 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.tests.integration.persistence;
 
+import org.apache.activemq.artemis.core.config.StoreConfiguration;
 import org.junit.Before;
 
 import org.junit.Test;
@@ -31,6 +32,10 @@ public class RolesConfigurationStorageTest extends StorageManagerTestBase {
 
    private Map<SimpleString, PersistedRoles> mapExpectedSets;
 
+   public RolesConfigurationStorageTest(StoreConfiguration.StoreType storeType) {
+      super(storeType);
+   }
+
    @Override
    @Before
    public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64f74acd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java
index 5b2760f..07b00db 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java
@@ -16,9 +16,19 @@
  */
 package org.apache.activemq.artemis.tests.integration.persistence;
 
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.ExecutorService;
+
 import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.StoreConfiguration;
 import org.apache.activemq.artemis.core.persistence.GroupingInfo;
 import org.apache.activemq.artemis.core.persistence.QueueBindingInfo;
+import org.apache.activemq.artemis.core.persistence.StorageManager;
+import org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
 import org.apache.activemq.artemis.jms.persistence.JMSStorageManager;
 import org.apache.activemq.artemis.jms.persistence.impl.journal.JMSJournalStorageManagerImpl;
@@ -29,23 +39,39 @@ import org.apache.activemq.artemis.utils.ExecutorFactory;
 import org.apache.activemq.artemis.utils.TimeAndCounterIDGenerator;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
-import java.util.ArrayList;
-import java.util.concurrent.ExecutorService;
-
+@RunWith(Parameterized.class)
 public abstract class StorageManagerTestBase extends ActiveMQTestBase {
 
    protected ExecutorService executor;
 
    protected ExecutorFactory execFactory;
 
-   protected JournalStorageManager journal;
+   protected StorageManager journal;
 
    protected JMSStorageManager jmsJournal;
 
+   protected StoreConfiguration.StoreType storeType;
+
+   public StorageManagerTestBase(StoreConfiguration.StoreType storeType) {
+      this.storeType = storeType;
+   }
+
+   @Parameterized.Parameters(name = "storeType")
+   public static Collection<Object[]> data() {
+      Object[][] params = new Object[][] {{StoreConfiguration.StoreType.FILE}, {StoreConfiguration.StoreType.DATABASE}};
+      return Arrays.asList(params);
+   }
+
    @Override
    @Before
    public void setUp() throws Exception {
+      if (storeType == StoreConfiguration.StoreType.DATABASE) {
+         Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
+      }
+
       super.setUp();
 
       execFactory = getOrderedExecutor();
@@ -79,6 +105,15 @@ public abstract class StorageManagerTestBase extends ActiveMQTestBase {
          jmsJournal = null;
       }
 
+      // Stops the database engine early to stop thread leaks showing.
+      if (storeType == StoreConfiguration.StoreType.DATABASE) {
+         try {
+            DriverManager.getConnection("jdbc:derby:;shutdown=true");
+         }
+         catch (SQLException e) {
+         }
+      }
+
       super.tearDown();
       if (exception != null)
          throw exception;
@@ -88,7 +123,13 @@ public abstract class StorageManagerTestBase extends ActiveMQTestBase {
     * @throws Exception
     */
    protected void createStorage() throws Exception {
-      journal = createJournalStorageManager(createDefaultInVMConfig());
+
+      if (storeType == StoreConfiguration.StoreType.DATABASE) {
+         journal = createJDBCJournalStorageManager(createDefaultJDBCConfig());
+      }
+      else {
+         journal = createJournalStorageManager(createDefaultInVMConfig());
+      }
 
       journal.start();
 
@@ -107,6 +148,15 @@ public abstract class StorageManagerTestBase extends ActiveMQTestBase {
    }
 
    /**
+    * @param configuration
+    */
+   protected JDBCJournalStorageManager createJDBCJournalStorageManager(Configuration configuration) {
+      JDBCJournalStorageManager jsm = new JDBCJournalStorageManager(configuration, execFactory, null);
+      addActiveMQComponent(jsm);
+      return jsm;
+   }
+
+   /**
     * @throws Exception
     */
    protected void createJMSStorage() throws Exception {
@@ -115,4 +165,5 @@ public abstract class StorageManagerTestBase extends ActiveMQTestBase {
       jmsJournal.start();
       jmsJournal.load();
    }
+
 }


Mime
View raw message