activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r378023 - in /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc: JDBCMessageStore.java JDBCPersistenceAdapter.java JDBCTopicMessageStore.java TransactionContext.java adapter/DefaultJDBCAdapter.java
Date Wed, 15 Feb 2006 15:51:15 GMT
Author: chirino
Date: Wed Feb 15 07:51:11 2006
New Revision: 378023

URL: http://svn.apache.org/viewcvs?rev=378023&view=rev
Log:
http://jira.activemq.org/jira/browse/AMQ-564

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCMessageStore.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCTopicMessageStore.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCMessageStore.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCMessageStore.java?rev=378023&r1=378022&r2=378023&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCMessageStore.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCMessageStore.java
Wed Feb 15 07:51:11 2006
@@ -66,6 +66,7 @@
         try {
             adapter.doAddMessage(c, message.getMessageId(), destination, data, message.getExpiration());
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to broker message: " + message.getMessageId()
+ " in container: "
                     + e, e);
         } finally {
@@ -79,6 +80,7 @@
         try {
             adapter.doAddMessageReference(c, messageId, destination, expirationTime, messageRef);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to broker message: " + messageId + "
in container: "
                     + e, e);
         } finally {
@@ -102,6 +104,7 @@
         } catch (IOException e) {
             throw IOExceptionSupport.create("Failed to broker message: " + messageId + "
in container: " + e, e);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to broker message: " + messageId + "
in container: " + e, e);
         } finally {
             c.close();
@@ -118,6 +121,7 @@
         } catch (IOException e) {
             throw IOExceptionSupport.create("Failed to broker message: " + messageId + "
in container: " + e, e);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to broker message: " + messageId + "
in container: " + e, e);
         } finally {
             c.close();
@@ -132,6 +136,7 @@
         try {
             adapter.doRemoveMessage(c, seq);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to broker message: " + ack.getLastMessageId()
+ " in container: " + e, e);
         } finally {
             c.close();
@@ -155,6 +160,7 @@
                 }
             });
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to recover container. Reason: " + e,
e);
         } finally {
             c.close();
@@ -176,6 +182,7 @@
         try {
             adapter.doRemoveAllMessages(c, destination);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to broker remove all messages: " + e,
e);
         } finally {
             c.close();

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java?rev=378023&r1=378022&r2=378023&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
Wed Feb 15 07:51:11 2006
@@ -87,6 +87,7 @@
         } catch (IOException e) {
             return Collections.EMPTY_SET;
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             return Collections.EMPTY_SET;
         } finally {
             try {
@@ -125,6 +126,7 @@
         try {
             return getAdapter().doGetLastMessageBrokerSequenceId(c);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to get last broker message id: " + e,
e);
         } finally {
             c.close();
@@ -141,7 +143,8 @@
             try {
                 getAdapter().doCreateTables(transactionContext);
             } catch (SQLException e) {
-                log.warn("Cannot create tables due to: " + e, e);
+                log.warn("Cannot create tables due to: " + e);
+                JDBCPersistenceAdapter.log("Failure Details: ",e);
             }
         } finally {
             transactionContext.commit();
@@ -176,7 +179,8 @@
         } catch (IOException e) {
             log.warn("Old message cleanup failed due to: " + e, e);
         } catch (SQLException e) {
-            log.warn("Old message cleanup failed due to: " + e, e);
+            log.warn("Old message cleanup failed due to: " + e);
+            JDBCPersistenceAdapter.log("Failure Details: ",e);
         } finally {
             try {
                 c.close();
@@ -237,10 +241,9 @@
                     }
 
                 } catch (SQLException e) {
-                    log
-                            .warn("JDBC error occured while trying to detect database type.
 Will use default JDBC implementation: "
+                    log.warn("JDBC error occurred while trying to detect database type. 
Will use default JDBC implementation: "
                                     + e.getMessage());
-                    log.debug("Reason: " + e, e);
+                    JDBCPersistenceAdapter.log("Failure Details: ",e);
                 }
 
             } else {
@@ -348,6 +351,7 @@
             getAdapter().setUseExternalMessageReferences(isUseExternalMessageReferences());
             getAdapter().doCreateTables(c);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create(e);
         } finally {
             c.close();
@@ -361,4 +365,14 @@
     public void setUseExternalMessageReferences(boolean useExternalMessageReferences) {
         this.useExternalMessageReferences = useExternalMessageReferences;
     }
+    
+    static public void log(String msg, SQLException e) {
+        String s = msg+e.getMessage();
+        while( e.getNextException() != null ) {
+            e = e.getNextException();
+            s += ", due to: "+e.getMessage();
+        }
+        log.debug(s, e);
+    }
+
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCTopicMessageStore.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCTopicMessageStore.java?rev=378023&r1=378022&r2=378023&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCTopicMessageStore.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCTopicMessageStore.java
Wed Feb 15 07:51:11 2006
@@ -48,6 +48,7 @@
         try {
             adapter.doSetLastAck(c, destination, clientId, subscriptionName, seq);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to store acknowledgment for: " + clientId
+ " on message "
                     + messageId + " in container: " + e, e);
         } finally {
@@ -76,6 +77,7 @@
                         }
                     });
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to recover subscription: " + clientId
+ ". Reason: " + e, e);
         } finally {
             c.close();
@@ -93,6 +95,7 @@
             c = persistenceAdapter.getTransactionContext();
             adapter.doSetSubscriberEntry(c, destination, clientId, subscriptionName, selector,
retroactive);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport
                     .create("Failed to lookup subscription for info: " + clientId + ". Reason:
" + e, e);
         } finally {
@@ -109,6 +112,7 @@
         try {
             return adapter.doGetSubscriberEntry(c, destination, clientId, subscriptionName);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to lookup subscription for: " + clientId
+ ". Reason: " + e, e);
         } finally {
             c.close();
@@ -120,6 +124,7 @@
         try {
             adapter.doDeleteSubscription(c, destination, clientId, subscriptionName);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to remove subscription for: " + clientId
+ ". Reason: " + e, e);
         } finally {
             c.close();
@@ -131,6 +136,7 @@
         try {
             return adapter.doGetAllSubscriptions(c, destination);
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("JDBC Failure: ",e);
             throw IOExceptionSupport.create("Failed to lookup subscriptions. Reason: " +
e, e);
         } finally {
             c.close();

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java?rev=378023&r1=378022&r2=378023&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
Wed Feb 15 07:51:11 2006
@@ -24,6 +24,8 @@
 import javax.sql.DataSource;
 
 import org.apache.activemq.util.IOExceptionSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Helps keep track of the current transaction/JDBC connection.
@@ -32,8 +34,7 @@
  */
 public class TransactionContext {
 
-    private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
-            .getLog(TransactionContext.class);
+    private static final Log log = LogFactory.getLog(TransactionContext.class);
     
     private final DataSource dataSource;
     private Connection connection;
@@ -52,6 +53,7 @@
                 connection = dataSource.getConnection();
                 connection.setAutoCommit(!inTx);
             } catch (SQLException e) {
+                JDBCPersistenceAdapter.log("Could not get JDBC connection: ", e);
                 throw IOExceptionSupport.create(e);
             }
             
@@ -117,6 +119,7 @@
                 }
                 
             } catch (SQLException e) {
+                JDBCPersistenceAdapter.log("Error while closing connection: ", e);
                 throw IOExceptionSupport.create(e);
             } finally {
                 try {
@@ -146,11 +149,7 @@
             executeBatch();
             connection.commit();
         } catch (SQLException e) {
-            log.info("commit failed: "+e.getMessage(), e);
-            while( e.getNextException() !=null ) {
-                e = e.getNextException();
-                log.info("Nested exception: "+e);
-            }
+            JDBCPersistenceAdapter.log("Commit failed: ", e);
             throw IOExceptionSupport.create(e);
         } finally {
             inTx=false;
@@ -177,6 +176,7 @@
             connection.rollback();
             
         } catch (SQLException e) {
+            JDBCPersistenceAdapter.log("Rollback failed: ", e);
             throw IOExceptionSupport.create(e);
         } finally {
             inTx=false;

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java?rev=378023&r1=378022&r2=378023&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
Wed Feb 15 07:51:11 2006
@@ -30,6 +30,7 @@
 import org.apache.activemq.command.SubscriptionInfo;
 import org.apache.activemq.store.jdbc.JDBCAdapter;
 import org.apache.activemq.store.jdbc.JDBCMessageRecoveryListener;
+import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
 import org.apache.activemq.store.jdbc.StatementProvider;
 import org.apache.activemq.store.jdbc.TransactionContext;
 import org.apache.commons.logging.Log;
@@ -112,6 +113,7 @@
                         log.warn("Could not create JDBC tables; they could already exist."
+
                             " Failure was: " + createStatments[i] + " Message: " + e.getMessage()
+
                             " SQLState: " + e.getSQLState() + " Vendor code: " + e.getErrorCode()
);
+                        JDBCPersistenceAdapter.log("Failure details: ",e);
                     }
                 }
             }
@@ -142,6 +144,7 @@
                     log.warn("Could not drop JDBC tables; they may not exist." +
                         " Failure was: " + dropStatments[i] + " Message: " + e.getMessage()
+
                         " SQLState: " + e.getSQLState() + " Vendor code: " + e.getErrorCode()
);
+                    JDBCPersistenceAdapter.log("Failure details: ",e);
                 }
             }
             c.getConnection().commit();



Mime
View raw message