activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r801612 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/store/jdbc/ main/java/org/apache/activemq/store/jdbc/adapter/ test/java/org/apache/activemq/store/jdbc/
Date Thu, 06 Aug 2009 11:46:36 GMT
Author: dejanb
Date: Thu Aug  6 11:46:35 2009
New Revision: 801612

URL: http://svn.apache.org/viewvc?rev=801612&view=rev
Log:
fix for https://issues.apache.org/activemq/browse/AMQ-1886 - jdbc adapter without journal
+ test case

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/jdbc/
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DB2JDBCAdapter.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java?rev=801612&r1=801611&r2=801612&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
Thu Aug  6 11:46:35 2009
@@ -162,10 +162,13 @@
             }
         } catch (SQLException e) {
             JDBCPersistenceAdapter.log("Commit failed: ", e);
+            
+            this.rollback(); 
+            
             throw IOExceptionSupport.create(e);
         } finally {
-            inTx = false;
             close();
+            inTx = false;
         }
     }
 
@@ -192,8 +195,8 @@
             JDBCPersistenceAdapter.log("Rollback failed: ", e);
             throw IOExceptionSupport.create(e);
         } finally {
-            inTx = false;
             close();
+            inTx = false;
         }
     }
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DB2JDBCAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DB2JDBCAdapter.java?rev=801612&r1=801611&r2=801612&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DB2JDBCAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DB2JDBCAdapter.java
Thu Aug  6 11:46:35 2009
@@ -27,9 +27,6 @@
  * @org.apache.xbean.XBean element="db2JDBCAdapter"
  */
 public class DB2JDBCAdapter extends DefaultJDBCAdapter {
-    public DB2JDBCAdapter() {
-        batchStatments = false;
-    }
 
     public void setStatements(Statements statements) {
         String lockCreateStatement = "LOCK TABLE " + statements.getFullLockTableName() +
" IN EXCLUSIVE MODE";

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java?rev=801612&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java
Thu Aug  6 11:46:35 2009
@@ -0,0 +1,44 @@
+package org.apache.activemq.store.jdbc;
+
+import junit.framework.Test;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.BrokerTest;
+import org.apache.derby.jdbc.EmbeddedDataSource;
+
+public class JDBCStoreBrokerTest extends BrokerTest {
+
+    protected BrokerService createBroker() throws Exception {
+        BrokerService broker = new BrokerService();
+        JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
+        EmbeddedDataSource dataSource = new EmbeddedDataSource();
+        dataSource.setDatabaseName("derbyDb");
+        dataSource.setCreateDatabase("create");
+        jdbc.setDataSource(dataSource);
+        
+        jdbc.deleteAllMessages();
+        broker.setPersistenceAdapter(jdbc);
+        return broker;
+    }
+    
+    protected BrokerService createRestartedBroker() throws Exception {
+        BrokerService broker = new BrokerService();
+        JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
+        EmbeddedDataSource dataSource = new EmbeddedDataSource();
+        dataSource.setDatabaseName("derbyDb");
+        dataSource.setCreateDatabase("create");
+        jdbc.setDataSource(dataSource);
+        broker.setPersistenceAdapter(jdbc);
+        return broker;
+    }
+    
+    
+    public static Test suite() {
+        return suite(JDBCStoreBrokerTest.class);
+    }
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(suite());
+    }
+	
+}



Mime
View raw message