Class DefaultJDBCAdapter
java.lang.Object
org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter
- All Implemented Interfaces:
JDBCAdapter
- Direct Known Subclasses:
BlobJDBCAdapter,BytesJDBCAdapter,DB2JDBCAdapter,ImageBasedJDBCAdaptor,MaxDBJDBCAdapter,MySqlJDBCAdapter,OracleJDBCAdapter,SqlServerJDBCAdapter,StreamJDBCAdapter
Implements all the default JDBC operations that are used by the JDBCPersistenceAdapter. sub-classing is
encouraged to override the default implementation of methods to account for differences in JDBC Driver
implementations. The JDBCAdapter inserts and extracts BLOB data using the getBytes()/setBytes() operations.
The databases/JDBC drivers that use this adapter are:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatic final intprotected intprotected booleanprotected Statements -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidprotected static voidvoiddoAddMessage(TransactionContext c, long sequence, org.apache.activemq.command.MessageId messageID, org.apache.activemq.command.ActiveMQDestination destination, byte[] data, long expiration, byte priority, org.apache.activemq.command.XATransactionId xid) A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcomevoiddoAddMessageReference(TransactionContext c, long sequence, org.apache.activemq.command.MessageId messageID, org.apache.activemq.command.ActiveMQDestination destination, long expirationTime, String messageRef) voiddoClearLastAck(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, byte priority, String clientId, String subName) voiddoCommitAddOp(TransactionContext c, long preparedSequence, long sequence) voiddoCreateTables(TransactionContext transactionContext) voidvoiddoDeleteSubscription(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName) voidorg.apache.activemq.command.SubscriptionInfo[]doGetAllSubscriptions(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination) Set<org.apache.activemq.command.ActiveMQDestination>intdoGetDurableSubscriberMessageCount(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName, boolean isPrioritizedMessages) longdoGetLastAckedDurableSubscriberMessageId(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriberName) longlongdoGetLastProducerSequenceId(TransactionContext c, org.apache.activemq.command.ProducerId id) byte[]doGetMessage(TransactionContext c, org.apache.activemq.command.MessageId id) byte[]doGetMessageById(TransactionContext c, long storeSequenceId) intdoGetMessageCount(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination) doGetMessageReference(TransactionContext c, long seq) org.apache.activemq.command.SubscriptionInfodoGetSubscriberEntry(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName) voiddoMessageIdScan(TransactionContext c, int limit, JDBCMessageIdScanListener listener) voiddoRecordDestination(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination) voiddoRecover(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, JDBCMessageRecoveryListener listener) voiddoRecoverNextMessages(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, long[] lastRecoveredEntries, long maxSeq, int maxReturned, boolean isPrioritizedMessages, JDBCMessageRecoveryListener listener) voiddoRecoverNextMessages(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long priority, int maxReturned, JDBCMessageRecoveryListener listener) voiddoRecoverNextMessagesWithPriority(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long priority, int maxReturned, JDBCMessageRecoveryListener listener) voiddoRecoverPreparedOps(TransactionContext c, JdbcMemoryTransactionStore jdbcMemoryTransactionStore) voiddoRecoverSubscription(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName, JDBCMessageRecoveryListener listener) voiddoRemoveAllMessages(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destinationName) voiddoRemoveMessage(TransactionContext c, long seq, org.apache.activemq.command.XATransactionId xid) A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcomevoiddoSetLastAck(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, org.apache.activemq.command.XATransactionId xid, String clientId, String subscriptionName, long seq, long priority) voiddoSetLastAckWithPriority(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, org.apache.activemq.command.XATransactionId xid, String clientId, String subscriptionName, long seq, long priority) voiddoSetSubscriberEntry(TransactionContext c, org.apache.activemq.command.SubscriptionInfo info, boolean retroactive, boolean isPrioritizedMessages) voiddoUpdateMessage(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, org.apache.activemq.command.MessageId id, byte[] data) static voidstatic voiddumpTables(Connection c, String destinationName, String clientId, String subscriptionName) protected byte[]getBinaryData(ResultSet rs, int index) intlong[]getStoreSequenceId(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, org.apache.activemq.command.MessageId messageID) booleanbooleanlimitQuery(String query) static voidprintQuery(Connection c, String query, PrintStream out) static voidprintQuery(PreparedStatement s, PrintStream out) voidsetBatchStatements(boolean batchStatements) Set the number of statements to process as a single batch DB updatevoidsetBatchStatments(boolean batchStatments) Deprecated.protected voidsetBinaryData(PreparedStatement s, int index, byte[] data) voidsetMaxRows(int maxRows) the max value for statement maxRows, used to limit jdbc queriesvoidsetStatements(Statements statements) voidsetUseExternalMessageReferences(boolean useExternalMessageReferences)
-
Field Details
-
MAX_ROWS
public static final int MAX_ROWS- See Also:
-
statements
-
batchStatments
protected boolean batchStatments -
prioritizedMessages
protected boolean prioritizedMessages -
maxRows
protected int maxRows
-
-
Constructor Details
-
DefaultJDBCAdapter
public DefaultJDBCAdapter()
-
-
Method Details
-
setBinaryData
- Throws:
SQLException
-
getBinaryData
- Throws:
SQLException
-
doCreateTables
- Specified by:
doCreateTablesin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doDropTables
- Specified by:
doDropTablesin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetLastMessageStoreSequenceId
- Specified by:
doGetLastMessageStoreSequenceIdin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetMessageById
public byte[] doGetMessageById(TransactionContext c, long storeSequenceId) throws SQLException, IOException - Specified by:
doGetMessageByIdin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doAddMessage
public void doAddMessage(TransactionContext c, long sequence, org.apache.activemq.command.MessageId messageID, org.apache.activemq.command.ActiveMQDestination destination, byte[] data, long expiration, byte priority, org.apache.activemq.command.XATransactionId xid) throws SQLException, IOException A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcome- Specified by:
doAddMessagein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doUpdateMessage
public void doUpdateMessage(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, org.apache.activemq.command.MessageId id, byte[] data) throws SQLException, IOException - Specified by:
doUpdateMessagein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doAddMessageReference
public void doAddMessageReference(TransactionContext c, long sequence, org.apache.activemq.command.MessageId messageID, org.apache.activemq.command.ActiveMQDestination destination, long expirationTime, String messageRef) throws SQLException, IOException - Specified by:
doAddMessageReferencein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
getStoreSequenceId
public long[] getStoreSequenceId(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, org.apache.activemq.command.MessageId messageID) throws SQLException, IOException - Specified by:
getStoreSequenceIdin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetMessage
public byte[] doGetMessage(TransactionContext c, org.apache.activemq.command.MessageId id) throws SQLException, IOException - Specified by:
doGetMessagein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetMessageReference
public String doGetMessageReference(TransactionContext c, long seq) throws SQLException, IOException - Specified by:
doGetMessageReferencein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRemoveMessage
public void doRemoveMessage(TransactionContext c, long seq, org.apache.activemq.command.XATransactionId xid) throws SQLException, IOException A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcome- Specified by:
doRemoveMessagein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRecover
public void doRecover(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, JDBCMessageRecoveryListener listener) throws Exception - Specified by:
doRecoverin interfaceJDBCAdapter- Throws:
Exception
-
doMessageIdScan
public void doMessageIdScan(TransactionContext c, int limit, JDBCMessageIdScanListener listener) throws SQLException, IOException - Specified by:
doMessageIdScanin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doSetLastAckWithPriority
public void doSetLastAckWithPriority(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, org.apache.activemq.command.XATransactionId xid, String clientId, String subscriptionName, long seq, long priority) throws SQLException, IOException - Specified by:
doSetLastAckWithPriorityin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doSetLastAck
public void doSetLastAck(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, org.apache.activemq.command.XATransactionId xid, String clientId, String subscriptionName, long seq, long priority) throws SQLException, IOException - Specified by:
doSetLastAckin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doClearLastAck
public void doClearLastAck(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, byte priority, String clientId, String subName) throws SQLException, IOException - Specified by:
doClearLastAckin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRecoverSubscription
public void doRecoverSubscription(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName, JDBCMessageRecoveryListener listener) throws Exception - Specified by:
doRecoverSubscriptionin interfaceJDBCAdapter- Throws:
Exception
-
doRecoverNextMessages
public void doRecoverNextMessages(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long priority, int maxReturned, JDBCMessageRecoveryListener listener) throws Exception - Specified by:
doRecoverNextMessagesin interfaceJDBCAdapter- Throws:
Exception
-
doRecoverNextMessagesWithPriority
public void doRecoverNextMessagesWithPriority(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long priority, int maxReturned, JDBCMessageRecoveryListener listener) throws Exception - Specified by:
doRecoverNextMessagesWithPriorityin interfaceJDBCAdapter- Throws:
Exception
-
doGetDurableSubscriberMessageCount
public int doGetDurableSubscriberMessageCount(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName, boolean isPrioritizedMessages) throws SQLException, IOException - Specified by:
doGetDurableSubscriberMessageCountin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doSetSubscriberEntry
public void doSetSubscriberEntry(TransactionContext c, org.apache.activemq.command.SubscriptionInfo info, boolean retroactive, boolean isPrioritizedMessages) throws SQLException, IOException - Specified by:
doSetSubscriberEntryin interfaceJDBCAdapter- Parameters:
c-info-retroactive-- Throws:
SQLExceptionIOException
-
doGetSubscriberEntry
public org.apache.activemq.command.SubscriptionInfo doGetSubscriberEntry(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName) throws SQLException, IOException - Specified by:
doGetSubscriberEntryin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetAllSubscriptions
public org.apache.activemq.command.SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination) throws SQLException, IOException - Specified by:
doGetAllSubscriptionsin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRemoveAllMessages
public void doRemoveAllMessages(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destinationName) throws SQLException, IOException - Specified by:
doRemoveAllMessagesin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doDeleteSubscription
public void doDeleteSubscription(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriptionName) throws SQLException, IOException - Specified by:
doDeleteSubscriptionin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doDeleteOldMessages
- Specified by:
doDeleteOldMessagesin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetLastAckedDurableSubscriberMessageId
public long doGetLastAckedDurableSubscriberMessageId(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, String clientId, String subscriberName) throws SQLException, IOException - Specified by:
doGetLastAckedDurableSubscriberMessageIdin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
close
-
close
-
doGetDestinations
public Set<org.apache.activemq.command.ActiveMQDestination> doGetDestinations(TransactionContext c) throws SQLException, IOException - Specified by:
doGetDestinationsin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
isBatchStatements
public boolean isBatchStatements()- Returns:
- true if batchStatements
-
setBatchStatements
public void setBatchStatements(boolean batchStatements) Set the number of statements to process as a single batch DB update- Parameters:
batchStatements-
-
isBatchStatments
public boolean isBatchStatments()- Returns:
- true if batchStements
-
setBatchStatments
public void setBatchStatments(boolean batchStatments) Deprecated.This value batchStatments is deprecated and will be removed in a future release. Use batchStatements instead (Note the 'e' in Statement)"- Parameters:
batchStatments-
-
setUseExternalMessageReferences
public void setUseExternalMessageReferences(boolean useExternalMessageReferences) - Specified by:
setUseExternalMessageReferencesin interfaceJDBCAdapter
-
getStatements
- Returns:
- the statements
-
setStatements
- Specified by:
setStatementsin interfaceJDBCAdapter
-
getMaxRows
public int getMaxRows()- Specified by:
getMaxRowsin interfaceJDBCAdapter
-
setMaxRows
public void setMaxRows(int maxRows) the max value for statement maxRows, used to limit jdbc queries- Specified by:
setMaxRowsin interfaceJDBCAdapter
-
doRecordDestination
public void doRecordDestination(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination) throws SQLException, IOException - Specified by:
doRecordDestinationin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRecoverPreparedOps
public void doRecoverPreparedOps(TransactionContext c, JdbcMemoryTransactionStore jdbcMemoryTransactionStore) throws SQLException, IOException - Specified by:
doRecoverPreparedOpsin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doCommitAddOp
public void doCommitAddOp(TransactionContext c, long preparedSequence, long sequence) throws SQLException, IOException - Specified by:
doCommitAddOpin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetMessageCount
public int doGetMessageCount(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination) throws SQLException, IOException - Specified by:
doGetMessageCountin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRecoverNextMessages
public void doRecoverNextMessages(TransactionContext c, org.apache.activemq.command.ActiveMQDestination destination, long[] lastRecoveredEntries, long maxSeq, int maxReturned, boolean isPrioritizedMessages, JDBCMessageRecoveryListener listener) throws Exception - Specified by:
doRecoverNextMessagesin interfaceJDBCAdapter- Throws:
Exception
-
doGetLastProducerSequenceId
public long doGetLastProducerSequenceId(TransactionContext c, org.apache.activemq.command.ProducerId id) throws SQLException, IOException - Specified by:
doGetLastProducerSequenceIdin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
dumpTables
public static void dumpTables(Connection c, String destinationName, String clientId, String subscriptionName) throws SQLException - Throws:
SQLException
-
dumpTables
- Throws:
SQLException
-
printQuery
- Throws:
SQLException
-
printQuery
- Throws:
SQLException
-
limitQuery
- Specified by:
limitQueryin interfaceJDBCAdapter
-