diff --git a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/H2JDBCAdapter.java b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/H2JDBCAdapter.java
new file mode 100644
index 00000000000..4d1560ca1b9
--- /dev/null
+++ b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/H2JDBCAdapter.java
@@ -0,0 +1,38 @@
+/**
+ * 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.store.jdbc.adapter;
+
+import org.apache.activemq.store.jdbc.Statements;
+
+/**
+ *
+ * @org.apache.xbean.XBean element="h2-jdbc-adapter"
+ */
+public class H2JDBCAdapter extends BytesJDBCAdapter {
+
+ @Override
+ public void setStatements(Statements statements) {
+ statements.setBinaryDataType("BLOB");
+ super.setStatements(statements);
+ }
+
+ @Override
+ public String limitQuery(String query) {
+ return query + " LIMIT " + getMaxRows();
+ }
+
+}
diff --git a/activemq-jdbc-store/src/main/resources/META-INF/services/org/apache/activemq/store/jdbc/h2_database_engine_driver b/activemq-jdbc-store/src/main/resources/META-INF/services/org/apache/activemq/store/jdbc/h2_database_engine_driver
new file mode 100644
index 00000000000..1513234f442
--- /dev/null
+++ b/activemq-jdbc-store/src/main/resources/META-INF/services/org/apache/activemq/store/jdbc/h2_database_engine_driver
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+class=org.apache.activemq.store.jdbc.adapter.H2JDBCAdapter
\ No newline at end of file
diff --git a/activemq-unit-tests/pom.xml b/activemq-unit-tests/pom.xml
index 38f589c66f0..848807e941c 100644
--- a/activemq-unit-tests/pom.xml
+++ b/activemq-unit-tests/pom.xml
@@ -128,6 +128,12 @@
org.springframework
spring-context
+
+ com.h2database
+ h2
+ test
+ true
+
org.apache.derby
derby
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java
index c19516f5508..c2abc1ccf6f 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java
@@ -22,19 +22,29 @@
import org.apache.activemq.broker.BrokerTest;
import org.apache.derby.jdbc.EmbeddedDataSource;
+import javax.sql.DataSource;
+
public class JDBCStoreBrokerTest extends BrokerTest {
+ protected void configureJDBCPersistenceAdapter(JDBCPersistenceAdapter jdbc, final String name) throws Exception {
+
+ }
+
+ @Override
protected BrokerService createBroker() throws Exception {
BrokerService broker = new BrokerService();
- JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
+ var jdbc = new JDBCPersistenceAdapter();
+ configureJDBCPersistenceAdapter(jdbc, "JDBCStoreBrokerTest");
jdbc.deleteAllMessages();
broker.setPersistenceAdapter(jdbc);
return broker;
}
-
+
protected BrokerService x_createRestartedBroker() throws Exception {
BrokerService broker = new BrokerService();
- broker.setPersistenceAdapter(new JDBCPersistenceAdapter());
+ var jdbc = new JDBCPersistenceAdapter();
+ configureJDBCPersistenceAdapter(jdbc, "JDBCStoreBrokerTest");
+ broker.setPersistenceAdapter(jdbc);
return broker;
}
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/h2/H2DB.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/h2/H2DB.java
new file mode 100644
index 00000000000..31b7afeafbd
--- /dev/null
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/h2/H2DB.java
@@ -0,0 +1,45 @@
+/**
+ * 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.store.jdbc.h2;
+
+import javax.sql.DataSource;
+import org.h2.jdbcx.JdbcDataSource;
+
+import java.io.IOException;
+
+public class H2DB {
+
+ public static DataSource createDataSource(String db) throws IOException {
+ var ds = new JdbcDataSource();
+ ds.setURL(createURL(db));
+ ds.setUser(getUser());
+ ds.setPassword(getPassword());
+ return ds;
+ }
+
+ public static String createURL(String db) {
+ return "jdbc:h2:./target/h2-db/" + db + "/" + db + "-h2.db;DB_CLOSE_DELAY=-1";
+ }
+
+ public static String getUser() {
+ return "sa";
+ }
+
+ public static String getPassword() {
+ return "";
+ }
+}
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/h2/H2JDBCStoreBrokerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/h2/H2JDBCStoreBrokerTest.java
new file mode 100644
index 00000000000..38e19327be2
--- /dev/null
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/h2/H2JDBCStoreBrokerTest.java
@@ -0,0 +1,37 @@
+/**
+ * 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.store.jdbc.h2;
+
+import junit.framework.Test;
+import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
+import org.apache.activemq.store.jdbc.JDBCStoreBrokerTest;
+import org.apache.activemq.store.jdbc.adapter.H2JDBCAdapter;
+
+import javax.sql.DataSource;
+
+public class H2JDBCStoreBrokerTest extends JDBCStoreBrokerTest {
+
+ @Override
+ protected void configureJDBCPersistenceAdapter(final JDBCPersistenceAdapter jdbc, String dbname) throws Exception {
+ jdbc.setDataSource(H2DB.createDataSource("H2JDBCStoreBrokerTest"));
+ jdbc.setAdapter(new H2JDBCAdapter());
+ }
+
+ public static Test suite() {
+ return suite(H2JDBCStoreBrokerTest.class);
+ }
+}
diff --git a/pom.xml b/pom.xml
index 434662fdf1f..534077a7a43 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,6 +74,7 @@
2.13.1
2.4.3
4.13.2
+ 2.4.240
1.3
4.3.7
2.25.3
@@ -766,6 +767,12 @@
${org-apache-derby-version}
+
+ com.h2database
+ h2
+ ${h2-version}
+
+
org.apache.commons
commons-dbcp2