org.apache.activemq.store.jdbc.adapter
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, StreamJDBCAdapter
public class DefaultJDBCAdapter
- extends java.lang.Object
- implements JDBCAdapter
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:
|
Method Summary |
protected static void |
close(java.sql.PreparedStatement s)
|
protected static void |
close(java.sql.ResultSet rs)
|
void |
doAddMessage(TransactionContext c,
long sequence,
MessageId messageID,
ActiveMQDestination destination,
byte[] data,
long expiration,
byte priority,
XATransactionId xid)
A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcome |
void |
doAddMessageReference(TransactionContext c,
long sequence,
MessageId messageID,
ActiveMQDestination destination,
long expirationTime,
java.lang.String messageRef)
|
void |
doClearLastAck(TransactionContext c,
ActiveMQDestination destination,
byte priority,
java.lang.String clientId,
java.lang.String subName)
|
void |
doCommitAddOp(TransactionContext c,
long sequence)
|
void |
doCreateTables(TransactionContext c)
|
void |
doDeleteOldMessages(TransactionContext c)
|
void |
doDeleteSubscription(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName)
|
void |
doDropTables(TransactionContext c)
|
SubscriptionInfo[] |
doGetAllSubscriptions(TransactionContext c,
ActiveMQDestination destination)
|
java.util.Set<ActiveMQDestination> |
doGetDestinations(TransactionContext c)
|
int |
doGetDurableSubscriberMessageCount(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName,
boolean isPrioritizedMessages)
|
long |
doGetLastAckedDurableSubscriberMessageId(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriberName)
|
long |
doGetLastMessageStoreSequenceId(TransactionContext c)
|
long |
doGetLastProducerSequenceId(TransactionContext c,
ProducerId id)
|
byte[] |
doGetMessage(TransactionContext c,
MessageId id)
|
byte[] |
doGetMessageById(TransactionContext c,
long storeSequenceId)
|
int |
doGetMessageCount(TransactionContext c,
ActiveMQDestination destination)
|
java.lang.String |
doGetMessageReference(TransactionContext c,
long seq)
|
SubscriptionInfo |
doGetSubscriberEntry(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName)
|
void |
doMessageIdScan(TransactionContext c,
int limit,
JDBCMessageIdScanListener listener)
|
void |
doRecordDestination(TransactionContext c,
ActiveMQDestination destination)
|
void |
doRecover(TransactionContext c,
ActiveMQDestination destination,
JDBCMessageRecoveryListener listener)
|
void |
doRecoverNextMessages(TransactionContext c,
ActiveMQDestination destination,
long nextSeq,
long priority,
int maxReturned,
boolean isPrioritizedMessages,
JDBCMessageRecoveryListener listener)
|
void |
doRecoverNextMessages(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long priority,
int maxReturned,
JDBCMessageRecoveryListener listener)
|
void |
doRecoverNextMessagesWithPriority(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long priority,
int maxReturned,
JDBCMessageRecoveryListener listener)
|
void |
doRecoverPreparedOps(TransactionContext c,
JdbcMemoryTransactionStore jdbcMemoryTransactionStore)
|
void |
doRecoverSubscription(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName,
JDBCMessageRecoveryListener listener)
|
void |
doRemoveAllMessages(TransactionContext c,
ActiveMQDestination destinationName)
|
void |
doRemoveMessage(TransactionContext c,
long seq,
XATransactionId xid)
A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcome |
void |
doSetLastAck(TransactionContext c,
ActiveMQDestination destination,
XATransactionId xid,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long priority)
|
void |
doSetLastAckWithPriority(TransactionContext c,
ActiveMQDestination destination,
XATransactionId xid,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long priority)
|
void |
doSetSubscriberEntry(TransactionContext c,
SubscriptionInfo info,
boolean retroactive,
boolean isPrioritizedMessages)
|
static void |
dumpTables(java.sql.Connection c)
|
static void |
dumpTables(java.sql.Connection c,
java.lang.String destinationName,
java.lang.String clientId,
java.lang.String subscriptionName)
|
protected byte[] |
getBinaryData(java.sql.ResultSet rs,
int index)
|
int |
getMaxRows()
|
Statements |
getStatements()
|
long[] |
getStoreSequenceId(TransactionContext c,
ActiveMQDestination destination,
MessageId messageID)
|
boolean |
isBatchStatments()
|
static void |
printQuery(java.sql.Connection c,
java.lang.String query,
java.io.PrintStream out)
|
static void |
printQuery(java.sql.PreparedStatement s,
java.io.PrintStream out)
|
void |
setBatchStatments(boolean batchStatments)
|
protected void |
setBinaryData(java.sql.PreparedStatement s,
int index,
byte[] data)
|
void |
setMaxRows(int maxRows)
the max value for statement maxRows, used to limit jdbc queries |
void |
setStatements(Statements statements)
|
void |
setUseExternalMessageReferences(boolean useExternalMessageReferences)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MAX_ROWS
public static final int MAX_ROWS
- See Also:
- Constant Field Values
statements
protected Statements statements
batchStatments
protected boolean batchStatments
prioritizedMessages
protected boolean prioritizedMessages
cleanupExclusiveLock
protected java.util.concurrent.locks.ReadWriteLock cleanupExclusiveLock
maxRows
protected int maxRows
DefaultJDBCAdapter
public DefaultJDBCAdapter()
setBinaryData
protected void setBinaryData(java.sql.PreparedStatement s,
int index,
byte[] data)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
getBinaryData
protected byte[] getBinaryData(java.sql.ResultSet rs,
int index)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
doCreateTables
public void doCreateTables(TransactionContext c)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doCreateTables in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doDropTables
public void doDropTables(TransactionContext c)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doDropTables in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doGetLastMessageStoreSequenceId
public long doGetLastMessageStoreSequenceId(TransactionContext c)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetLastMessageStoreSequenceId in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doGetMessageById
public byte[] doGetMessageById(TransactionContext c,
long storeSequenceId)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetMessageById in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doAddMessage
public void doAddMessage(TransactionContext c,
long sequence,
MessageId messageID,
ActiveMQDestination destination,
byte[] data,
long expiration,
byte priority,
XATransactionId xid)
throws java.sql.SQLException,
java.io.IOException
- A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcome
- Specified by:
doAddMessage in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doAddMessageReference
public void doAddMessageReference(TransactionContext c,
long sequence,
MessageId messageID,
ActiveMQDestination destination,
long expirationTime,
java.lang.String messageRef)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doAddMessageReference in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
getStoreSequenceId
public long[] getStoreSequenceId(TransactionContext c,
ActiveMQDestination destination,
MessageId messageID)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
getStoreSequenceId in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doGetMessage
public byte[] doGetMessage(TransactionContext c,
MessageId id)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetMessage in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doGetMessageReference
public java.lang.String doGetMessageReference(TransactionContext c,
long seq)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetMessageReference in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doRemoveMessage
public void doRemoveMessage(TransactionContext c,
long seq,
XATransactionId xid)
throws java.sql.SQLException,
java.io.IOException
- A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcome
- Specified by:
doRemoveMessage in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doRecover
public void doRecover(TransactionContext c,
ActiveMQDestination destination,
JDBCMessageRecoveryListener listener)
throws java.lang.Exception
- Specified by:
doRecover in interface JDBCAdapter
- Throws:
java.lang.Exception
doMessageIdScan
public void doMessageIdScan(TransactionContext c,
int limit,
JDBCMessageIdScanListener listener)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doMessageIdScan in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doSetLastAckWithPriority
public void doSetLastAckWithPriority(TransactionContext c,
ActiveMQDestination destination,
XATransactionId xid,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long priority)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doSetLastAckWithPriority in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doSetLastAck
public void doSetLastAck(TransactionContext c,
ActiveMQDestination destination,
XATransactionId xid,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long priority)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doSetLastAck in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doClearLastAck
public void doClearLastAck(TransactionContext c,
ActiveMQDestination destination,
byte priority,
java.lang.String clientId,
java.lang.String subName)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doClearLastAck in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doRecoverSubscription
public void doRecoverSubscription(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName,
JDBCMessageRecoveryListener listener)
throws java.lang.Exception
- Specified by:
doRecoverSubscription in interface JDBCAdapter
- Throws:
java.lang.Exception
doRecoverNextMessages
public void doRecoverNextMessages(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long priority,
int maxReturned,
JDBCMessageRecoveryListener listener)
throws java.lang.Exception
- Specified by:
doRecoverNextMessages in interface JDBCAdapter
- Throws:
java.lang.Exception
doRecoverNextMessagesWithPriority
public void doRecoverNextMessagesWithPriority(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long priority,
int maxReturned,
JDBCMessageRecoveryListener listener)
throws java.lang.Exception
- Specified by:
doRecoverNextMessagesWithPriority in interface JDBCAdapter
- Throws:
java.lang.Exception
doGetDurableSubscriberMessageCount
public int doGetDurableSubscriberMessageCount(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName,
boolean isPrioritizedMessages)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetDurableSubscriberMessageCount in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doSetSubscriberEntry
public void doSetSubscriberEntry(TransactionContext c,
SubscriptionInfo info,
boolean retroactive,
boolean isPrioritizedMessages)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doSetSubscriberEntry in interface JDBCAdapter
- Parameters:
c - info - retroactive -
- Throws:
java.sql.SQLException
java.io.IOException
doGetSubscriberEntry
public SubscriptionInfo doGetSubscriberEntry(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetSubscriberEntry in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doGetAllSubscriptions
public SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c,
ActiveMQDestination destination)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetAllSubscriptions in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doRemoveAllMessages
public void doRemoveAllMessages(TransactionContext c,
ActiveMQDestination destinationName)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doRemoveAllMessages in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doDeleteSubscription
public void doDeleteSubscription(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doDeleteSubscription in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doDeleteOldMessages
public void doDeleteOldMessages(TransactionContext c)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doDeleteOldMessages in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doGetLastAckedDurableSubscriberMessageId
public long doGetLastAckedDurableSubscriberMessageId(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriberName)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetLastAckedDurableSubscriberMessageId in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
close
protected static void close(java.sql.PreparedStatement s)
close
protected static void close(java.sql.ResultSet rs)
doGetDestinations
public java.util.Set<ActiveMQDestination> doGetDestinations(TransactionContext c)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetDestinations in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
isBatchStatments
public boolean isBatchStatments()
- Returns:
- true if batchStements
setBatchStatments
public void setBatchStatments(boolean batchStatments)
- Parameters:
batchStatments -
setUseExternalMessageReferences
public void setUseExternalMessageReferences(boolean useExternalMessageReferences)
- Specified by:
setUseExternalMessageReferences in interface JDBCAdapter
getStatements
public Statements getStatements()
- Returns:
- the statements
setStatements
public void setStatements(Statements statements)
- Specified by:
setStatements in interface JDBCAdapter
getMaxRows
public int getMaxRows()
- Specified by:
getMaxRows in interface JDBCAdapter
setMaxRows
public void setMaxRows(int maxRows)
- the max value for statement maxRows, used to limit jdbc queries
- Specified by:
setMaxRows in interface JDBCAdapter
doRecordDestination
public void doRecordDestination(TransactionContext c,
ActiveMQDestination destination)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doRecordDestination in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doRecoverPreparedOps
public void doRecoverPreparedOps(TransactionContext c,
JdbcMemoryTransactionStore jdbcMemoryTransactionStore)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doRecoverPreparedOps in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doCommitAddOp
public void doCommitAddOp(TransactionContext c,
long sequence)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doCommitAddOp in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doGetMessageCount
public int doGetMessageCount(TransactionContext c,
ActiveMQDestination destination)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetMessageCount in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
doRecoverNextMessages
public void doRecoverNextMessages(TransactionContext c,
ActiveMQDestination destination,
long nextSeq,
long priority,
int maxReturned,
boolean isPrioritizedMessages,
JDBCMessageRecoveryListener listener)
throws java.lang.Exception
- Specified by:
doRecoverNextMessages in interface JDBCAdapter
- Throws:
java.lang.Exception
doGetLastProducerSequenceId
public long doGetLastProducerSequenceId(TransactionContext c,
ProducerId id)
throws java.sql.SQLException,
java.io.IOException
- Specified by:
doGetLastProducerSequenceId in interface JDBCAdapter
- Throws:
java.sql.SQLException
java.io.IOException
dumpTables
public static void dumpTables(java.sql.Connection c,
java.lang.String destinationName,
java.lang.String clientId,
java.lang.String subscriptionName)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
dumpTables
public static void dumpTables(java.sql.Connection c)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
printQuery
public static void printQuery(java.sql.Connection c,
java.lang.String query,
java.io.PrintStream out)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
printQuery
public static void printQuery(java.sql.PreparedStatement s,
java.io.PrintStream out)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
Copyright © 2005-2015 Red Hat, Inc.. All Rights Reserved.