mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@378023 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1667ce651b
commit
911177eb6c
|
@ -66,6 +66,7 @@ public class JDBCMessageStore implements MessageStore {
|
|||
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 @@ public class JDBCMessageStore implements MessageStore {
|
|||
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 @@ public class JDBCMessageStore implements MessageStore {
|
|||
} 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 @@ public class JDBCMessageStore implements MessageStore {
|
|||
} 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 @@ public class JDBCMessageStore implements MessageStore {
|
|||
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 @@ public class JDBCMessageStore implements MessageStore {
|
|||
}
|
||||
});
|
||||
} 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 @@ public class JDBCMessageStore implements MessageStore {
|
|||
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();
|
||||
|
|
|
@ -87,6 +87,7 @@ public class JDBCPersistenceAdapter implements PersistenceAdapter {
|
|||
} 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 @@ public class JDBCPersistenceAdapter implements PersistenceAdapter {
|
|||
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 @@ public class JDBCPersistenceAdapter implements PersistenceAdapter {
|
|||
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 @@ public class JDBCPersistenceAdapter implements PersistenceAdapter {
|
|||
} 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 @@ public class JDBCPersistenceAdapter implements PersistenceAdapter {
|
|||
}
|
||||
|
||||
} 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 @@ public class JDBCPersistenceAdapter implements PersistenceAdapter {
|
|||
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 class JDBCPersistenceAdapter implements PersistenceAdapter {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public class JDBCTopicMessageStore extends JDBCMessageStore implements TopicMess
|
|||
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 @@ public class JDBCTopicMessageStore extends JDBCMessageStore implements TopicMess
|
|||
}
|
||||
});
|
||||
} 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 @@ public class JDBCTopicMessageStore extends JDBCMessageStore implements TopicMess
|
|||
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 @@ public class JDBCTopicMessageStore extends JDBCMessageStore implements TopicMess
|
|||
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 @@ public class JDBCTopicMessageStore extends JDBCMessageStore implements TopicMess
|
|||
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 @@ public class JDBCTopicMessageStore extends JDBCMessageStore implements TopicMess
|
|||
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();
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.sql.SQLException;
|
|||
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 @@ import org.apache.activemq.util.IOExceptionSupport;
|
|||
*/
|
||||
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 @@ public class TransactionContext {
|
|||
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 @@ public class TransactionContext {
|
|||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
JDBCPersistenceAdapter.log("Error while closing connection: ", e);
|
||||
throw IOExceptionSupport.create(e);
|
||||
} finally {
|
||||
try {
|
||||
|
@ -146,11 +149,7 @@ public class TransactionContext {
|
|||
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 @@ public class TransactionContext {
|
|||
connection.rollback();
|
||||
|
||||
} catch (SQLException e) {
|
||||
JDBCPersistenceAdapter.log("Rollback failed: ", e);
|
||||
throw IOExceptionSupport.create(e);
|
||||
} finally {
|
||||
inTx=false;
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.activemq.command.MessageId;
|
|||
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 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
|
|||
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 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
|
|||
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();
|
||||
|
|
Loading…
Reference in New Issue