activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject git commit: Applying https://github.com/apache/activemq/pull/18.patch to fix AMQ-5116: batchStatment is misspelled for JDBC adaptors.
Date Fri, 21 Mar 2014 17:52:48 GMT
Repository: activemq
Updated Branches:
  refs/heads/trunk db321727c -> ff409b6f2


Applying https://github.com/apache/activemq/pull/18.patch to fix AMQ-5116: batchStatment is
misspelled for JDBC adaptors.  

This closes #18 @github.  

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/ff409b6f
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/ff409b6f
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/ff409b6f

Branch: refs/heads/trunk
Commit: ff409b6f2c790b15a7b9078fe49be896e71f1006
Parents: db32172
Author: Hiram Chirino <hiram@hiramchirino.com>
Authored: Fri Mar 21 13:52:41 2014 -0400
Committer: Hiram Chirino <hiram@hiramchirino.com>
Committed: Fri Mar 21 13:52:41 2014 -0400

----------------------------------------------------------------------
 .../store/jdbc/adapter/DefaultJDBCAdapter.java  | 57 ++++++++++++++------
 1 file changed, 41 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/ff409b6f/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
----------------------------------------------------------------------
diff --git a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
index cabe99c..3243048 100755
--- a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
+++ b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
@@ -65,6 +65,8 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
     private static final Logger LOG = LoggerFactory.getLogger(DefaultJDBCAdapter.class);
     public static final int MAX_ROWS = org.apache.activemq.ActiveMQPrefetchPolicy.MAX_PREFETCH_SIZE;
     protected Statements statements;
+    private boolean batchStatements = true;
+    //This is deprecated and should be removed in a future release
     protected boolean batchStatments = true;
     protected boolean prioritizedMessages;
     protected ReadWriteLock cleanupExclusiveLock = new ReentrantReadWriteLock();
@@ -216,7 +218,7 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
         try {
             if (s == null) {
                 s = c.getConnection().prepareStatement(this.statements.getAddMessageStatement());
-                if (this.batchStatments) {
+                if (this.batchStatements) {
                     c.setAddMessageStatement(s);
                 }
             }
@@ -235,14 +237,14 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
             } else {
                 s.setString(8, null);
             }
-            if (this.batchStatments) {
+            if (this.batchStatements) {
                 s.addBatch();
             } else if (s.executeUpdate() != 1) {
                 throw new SQLException("Failed add a message");
             }
         } finally {
             cleanupExclusiveLock.readLock().unlock();
-            if (!this.batchStatments) {
+            if (!this.batchStatements) {
                 if (s != null) {
                     s.close();
                 }
@@ -259,7 +261,7 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
         try {
             if (s == null) {
                 s = c.getConnection().prepareStatement(this.statements.getAddMessageStatement());
-                if (this.batchStatments) {
+                if (this.batchStatements) {
                     c.setAddMessageStatement(s);
                 }
             }
@@ -269,14 +271,14 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
             s.setString(4, destination.getQualifiedName());
             s.setLong(5, expirationTime);
             s.setString(6, messageRef);
-            if (this.batchStatments) {
+            if (this.batchStatements) {
                 s.addBatch();
             } else if (s.executeUpdate() != 1) {
                 throw new SQLException("Failed add a message");
             }
         } finally {
             cleanupExclusiveLock.readLock().unlock();
-            if (!this.batchStatments) {
+            if (!this.batchStatements) {
                 s.close();
             }
         }
@@ -352,7 +354,7 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
             if (s == null) {
                 s = c.getConnection().prepareStatement(xid == null ?
                         this.statements.getRemoveMessageStatement() : this.statements.getUpdateXidFlagStatement());
-                if (this.batchStatments) {
+                if (this.batchStatements) {
                     c.setRemovedMessageStatement(s);
                 }
             }
@@ -365,14 +367,14 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
                 s.setString(1, xidString);
                 s.setLong(2, seq);
             }
-            if (this.batchStatments) {
+            if (this.batchStatements) {
                 s.addBatch();
             } else if (s.executeUpdate() != 1) {
                 throw new SQLException("Failed to remove message");
             }
         } finally {
             cleanupExclusiveLock.readLock().unlock();
-            if (!this.batchStatments && s != null) {
+            if (!this.batchStatements && s != null) {
                 s.close();
             }
         }
@@ -443,7 +445,7 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
                 s = c.getConnection().prepareStatement(xid == null ?
                         this.statements.getUpdateDurableLastAckWithPriorityStatement() :
                         this.statements.getUpdateDurableLastAckWithPriorityInTxStatement());
-                if (this.batchStatments) {
+                if (this.batchStatements) {
                     c.setUpdateLastAckStatement(s);
                 }
             }
@@ -458,14 +460,14 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
             s.setString(3, clientId);
             s.setString(4, subscriptionName);
             s.setLong(5, priority);
-            if (this.batchStatments) {
+            if (this.batchStatements) {
                 s.addBatch();
             } else if (s.executeUpdate() != 1) {
                 throw new SQLException("Failed update last ack with priority: " + priority
+ ", for sub: " + subscriptionName);
             }
         } finally {
             cleanupExclusiveLock.readLock().unlock();
-            if (!this.batchStatments) {
+            if (!this.batchStatements) {
                 close(s);
             }
         }
@@ -481,7 +483,7 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
                 s = c.getConnection().prepareStatement(xid == null ?
                         this.statements.getUpdateDurableLastAckStatement() :
                         this.statements.getUpdateDurableLastAckInTxStatement());
-                if (this.batchStatments) {
+                if (this.batchStatements) {
                     c.setUpdateLastAckStatement(s);
                 }
             }
@@ -496,7 +498,7 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
             s.setString(3, clientId);
             s.setString(4, subscriptionName);
 
-            if (this.batchStatments) {
+            if (this.batchStatements) {
                 s.addBatch();
             } else if (s.executeUpdate() != 1) {
                 throw new IOException("Could not update last ack seq : "
@@ -504,7 +506,7 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
             }
         } finally {
             cleanupExclusiveLock.readLock().unlock();
-            if (!this.batchStatments) {
+            if (!this.batchStatements) {
                 close(s);
             }            
         }
@@ -893,16 +895,39 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
     }
 
     /**
+     * @return true if batchStatements
+     */
+    public boolean isBatchStatements() {
+        return batchStatements;
+    }
+
+    /**
+     * Set the number of statements to process as a single batch DB update
+     * @param batchStatements
+     */
+    public void setBatchStatements(boolean batchStatements) {
+        this.batchStatements = batchStatements;
+        // The next lines are deprecated and should be removed in a future release
+        // and is here in case someone created their own
+        this.batchStatments = batchStatements;
+    }
+
+    // Note - remove batchStatment in future distributions.  Here for backward compatibility
+    /**
      * @return true if batchStements
      */
     public boolean isBatchStatments() {
-        return this.batchStatments;
+        return this.batchStatements;
     }
 
     /**
+     * This value batchStatments is deprecated and will be removed in a future release. 
Use batchStatements instead (Note the 'e' in Statement)"
+     * @deprecated
      * @param batchStatments
      */
     public void setBatchStatments(boolean batchStatments) {
+        LOG.warn("batchStatments is deprecated and will be removed in a future release. 
Use batchStatements instead (Note the 'e' in Statement)");
+        this.batchStatements = batchStatments;
         this.batchStatments = batchStatments;
     }
 


Mime
View raw message