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 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(PreparedStatement s)
|
protected static void |
close(ResultSet rs)
|
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)
A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcome |
void |
doAddMessageReference(TransactionContext c,
long sequence,
org.apache.activemq.command.MessageId messageID,
org.apache.activemq.command.ActiveMQDestination destination,
long expirationTime,
String messageRef)
|
void |
doClearLastAck(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
byte priority,
String clientId,
String subName)
|
void |
doCommitAddOp(TransactionContext c,
long sequence)
|
void |
doCreateTables(TransactionContext c)
|
void |
doDeleteOldMessages(TransactionContext c)
|
void |
doDeleteSubscription(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
String clientId,
String subscriptionName)
|
void |
doDropTables(TransactionContext c)
|
org.apache.activemq.command.SubscriptionInfo[] |
doGetAllSubscriptions(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination)
|
Set<org.apache.activemq.command.ActiveMQDestination> |
doGetDestinations(TransactionContext c)
|
int |
doGetDurableSubscriberMessageCount(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
String clientId,
String subscriptionName,
boolean isPrioritizedMessages)
|
long |
doGetLastAckedDurableSubscriberMessageId(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
String clientId,
String subscriberName)
|
long |
doGetLastMessageStoreSequenceId(TransactionContext c)
|
long |
doGetLastProducerSequenceId(TransactionContext c,
org.apache.activemq.command.ProducerId id)
|
byte[] |
doGetMessage(TransactionContext c,
org.apache.activemq.command.MessageId id)
|
byte[] |
doGetMessageById(TransactionContext c,
long storeSequenceId)
|
int |
doGetMessageCount(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination)
|
String |
doGetMessageReference(TransactionContext c,
long seq)
|
org.apache.activemq.command.SubscriptionInfo |
doGetSubscriberEntry(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
String clientId,
String subscriptionName)
|
void |
doMessageIdScan(TransactionContext c,
int limit,
JDBCMessageIdScanListener listener)
|
void |
doRecordDestination(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination)
|
void |
doRecover(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
JDBCMessageRecoveryListener listener)
|
void |
doRecoverNextMessages(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
long nextSeq,
long priority,
int maxReturned,
boolean isPrioritizedMessages,
JDBCMessageRecoveryListener listener)
|
void |
doRecoverNextMessages(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
String clientId,
String subscriptionName,
long seq,
long priority,
int maxReturned,
JDBCMessageRecoveryListener listener)
|
void |
doRecoverNextMessagesWithPriority(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
String clientId,
String subscriptionName,
long seq,
long priority,
int maxReturned,
JDBCMessageRecoveryListener listener)
|
void |
doRecoverPreparedOps(TransactionContext c,
JdbcMemoryTransactionStore jdbcMemoryTransactionStore)
|
void |
doRecoverSubscription(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
String clientId,
String subscriptionName,
JDBCMessageRecoveryListener listener)
|
void |
doRemoveAllMessages(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destinationName)
|
void |
doRemoveMessage(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 outcome |
void |
doSetLastAck(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
org.apache.activemq.command.XATransactionId xid,
String clientId,
String subscriptionName,
long seq,
long priority)
|
void |
doSetLastAckWithPriority(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
org.apache.activemq.command.XATransactionId xid,
String clientId,
String subscriptionName,
long seq,
long priority)
|
void |
doSetSubscriberEntry(TransactionContext c,
org.apache.activemq.command.SubscriptionInfo info,
boolean retroactive,
boolean isPrioritizedMessages)
|
static void |
dumpTables(Connection c)
|
static void |
dumpTables(Connection c,
String destinationName,
String clientId,
String subscriptionName)
|
protected byte[] |
getBinaryData(ResultSet rs,
int index)
|
int |
getMaxRows()
|
Statements |
getStatements()
|
long[] |
getStoreSequenceId(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
org.apache.activemq.command.MessageId messageID)
|
boolean |
isBatchStatments()
|
static void |
printQuery(Connection c,
String query,
PrintStream out)
|
static void |
printQuery(PreparedStatement s,
PrintStream out)
|
void |
setBatchStatments(boolean batchStatments)
|
protected void |
setBinaryData(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 ReadWriteLock cleanupExclusiveLock
maxRows
protected int maxRows
DefaultJDBCAdapter
public DefaultJDBCAdapter()
setBinaryData
protected void setBinaryData(PreparedStatement s,
int index,
byte[] data)
throws SQLException
- Throws:
SQLException
getBinaryData
protected byte[] getBinaryData(ResultSet rs,
int index)
throws SQLException
- Throws:
SQLException
doCreateTables
public void doCreateTables(TransactionContext c)
throws SQLException,
IOException
- Specified by:
doCreateTables in interface JDBCAdapter
- Throws:
SQLException
IOException
doDropTables
public void doDropTables(TransactionContext c)
throws SQLException,
IOException
- Specified by:
doDropTables in interface JDBCAdapter
- Throws:
SQLException
IOException
doGetLastMessageStoreSequenceId
public long doGetLastMessageStoreSequenceId(TransactionContext c)
throws SQLException,
IOException
- Specified by:
doGetLastMessageStoreSequenceId in interface JDBCAdapter
- Throws:
SQLException
IOException
doGetMessageById
public byte[] doGetMessageById(TransactionContext c,
long storeSequenceId)
throws SQLException,
IOException
- Specified by:
doGetMessageById in interface JDBCAdapter
- Throws:
SQLException
IOException
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:
doAddMessage in interface JDBCAdapter
- Throws:
SQLException
IOException
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:
doAddMessageReference in interface JDBCAdapter
- Throws:
SQLException
IOException
getStoreSequenceId
public long[] getStoreSequenceId(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
org.apache.activemq.command.MessageId messageID)
throws SQLException,
IOException
- Specified by:
getStoreSequenceId in interface JDBCAdapter
- Throws:
SQLException
IOException
doGetMessage
public byte[] doGetMessage(TransactionContext c,
org.apache.activemq.command.MessageId id)
throws SQLException,
IOException
- Specified by:
doGetMessage in interface JDBCAdapter
- Throws:
SQLException
IOException
doGetMessageReference
public String doGetMessageReference(TransactionContext c,
long seq)
throws SQLException,
IOException
- Specified by:
doGetMessageReference in interface JDBCAdapter
- Throws:
SQLException
IOException
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:
doRemoveMessage in interface JDBCAdapter
- Throws:
SQLException
IOException
doRecover
public void doRecover(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
JDBCMessageRecoveryListener listener)
throws Exception
- Specified by:
doRecover in interface JDBCAdapter
- Throws:
Exception
doMessageIdScan
public void doMessageIdScan(TransactionContext c,
int limit,
JDBCMessageIdScanListener listener)
throws SQLException,
IOException
- Specified by:
doMessageIdScan in interface JDBCAdapter
- Throws:
SQLException
IOException
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:
doSetLastAckWithPriority in interface JDBCAdapter
- Throws:
SQLException
IOException
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:
doSetLastAck in interface JDBCAdapter
- Throws:
SQLException
IOException
doClearLastAck
public void doClearLastAck(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
byte priority,
String clientId,
String subName)
throws SQLException,
IOException
- Specified by:
doClearLastAck in interface JDBCAdapter
- Throws:
SQLException
IOException
doRecoverSubscription
public void doRecoverSubscription(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
String clientId,
String subscriptionName,
JDBCMessageRecoveryListener listener)
throws Exception
- Specified by:
doRecoverSubscription in interface JDBCAdapter
- 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:
doRecoverNextMessages in interface JDBCAdapter
- 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:
doRecoverNextMessagesWithPriority in interface JDBCAdapter
- 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:
doGetDurableSubscriberMessageCount in interface JDBCAdapter
- Throws:
SQLException
IOException
doSetSubscriberEntry
public void doSetSubscriberEntry(TransactionContext c,
org.apache.activemq.command.SubscriptionInfo info,
boolean retroactive,
boolean isPrioritizedMessages)
throws SQLException,
IOException
- Specified by:
doSetSubscriberEntry in interface JDBCAdapter
- Parameters:
c - info - retroactive -
- Throws:
SQLException
IOException
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:
doGetSubscriberEntry in interface JDBCAdapter
- Throws:
SQLException
IOException
doGetAllSubscriptions
public org.apache.activemq.command.SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination)
throws SQLException,
IOException
- Specified by:
doGetAllSubscriptions in interface JDBCAdapter
- Throws:
SQLException
IOException
doRemoveAllMessages
public void doRemoveAllMessages(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destinationName)
throws SQLException,
IOException
- Specified by:
doRemoveAllMessages in interface JDBCAdapter
- Throws:
SQLException
IOException
doDeleteSubscription
public void doDeleteSubscription(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
String clientId,
String subscriptionName)
throws SQLException,
IOException
- Specified by:
doDeleteSubscription in interface JDBCAdapter
- Throws:
SQLException
IOException
doDeleteOldMessages
public void doDeleteOldMessages(TransactionContext c)
throws SQLException,
IOException
- Specified by:
doDeleteOldMessages in interface JDBCAdapter
- Throws:
SQLException
IOException
doGetLastAckedDurableSubscriberMessageId
public long doGetLastAckedDurableSubscriberMessageId(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
String clientId,
String subscriberName)
throws SQLException,
IOException
- Specified by:
doGetLastAckedDurableSubscriberMessageId in interface JDBCAdapter
- Throws:
SQLException
IOException
close
protected static void close(PreparedStatement s)
close
protected static void close(ResultSet rs)
doGetDestinations
public Set<org.apache.activemq.command.ActiveMQDestination> doGetDestinations(TransactionContext c)
throws SQLException,
IOException
- Specified by:
doGetDestinations in interface JDBCAdapter
- Throws:
SQLException
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,
org.apache.activemq.command.ActiveMQDestination destination)
throws SQLException,
IOException
- Specified by:
doRecordDestination in interface JDBCAdapter
- Throws:
SQLException
IOException
doRecoverPreparedOps
public void doRecoverPreparedOps(TransactionContext c,
JdbcMemoryTransactionStore jdbcMemoryTransactionStore)
throws SQLException,
IOException
- Specified by:
doRecoverPreparedOps in interface JDBCAdapter
- Throws:
SQLException
IOException
doCommitAddOp
public void doCommitAddOp(TransactionContext c,
long sequence)
throws SQLException,
IOException
- Specified by:
doCommitAddOp in interface JDBCAdapter
- Throws:
SQLException
IOException
doGetMessageCount
public int doGetMessageCount(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination)
throws SQLException,
IOException
- Specified by:
doGetMessageCount in interface JDBCAdapter
- Throws:
SQLException
IOException
doRecoverNextMessages
public void doRecoverNextMessages(TransactionContext c,
org.apache.activemq.command.ActiveMQDestination destination,
long nextSeq,
long priority,
int maxReturned,
boolean isPrioritizedMessages,
JDBCMessageRecoveryListener listener)
throws Exception
- Specified by:
doRecoverNextMessages in interface JDBCAdapter
- Throws:
Exception
doGetLastProducerSequenceId
public long doGetLastProducerSequenceId(TransactionContext c,
org.apache.activemq.command.ProducerId id)
throws SQLException,
IOException
- Specified by:
doGetLastProducerSequenceId in interface JDBCAdapter
- Throws:
SQLException
IOException
dumpTables
public static void dumpTables(Connection c,
String destinationName,
String clientId,
String subscriptionName)
throws SQLException
- Throws:
SQLException
dumpTables
public static void dumpTables(Connection c)
throws SQLException
- Throws:
SQLException
printQuery
public static void printQuery(Connection c,
String query,
PrintStream out)
throws SQLException
- Throws:
SQLException
printQuery
public static void printQuery(PreparedStatement s,
PrintStream out)
throws SQLException
- Throws:
SQLException
Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.