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)
|
void |
doAddMessageReference(TransactionContext c,
long sequence,
MessageId messageID,
ActiveMQDestination destination,
long expirationTime,
java.lang.String messageRef)
|
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)
|
byte[] |
doGetNextDurableSubscriberMessageStatement(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriberName)
|
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 |
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)
|
void |
doSetLastAck(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long priority)
|
void |
doSetLastAckWithPriority(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long prio)
|
void |
doSetSubscriberEntry(TransactionContext c,
SubscriptionInfo info,
boolean retroactive,
boolean isPrioritizedMessages)
|
protected byte[] |
getBinaryData(java.sql.ResultSet rs,
int index)
|
int |
getMaxRows()
|
Statements |
getStatements()
|
long[] |
getStoreSequenceId(TransactionContext c,
ActiveMQDestination destination,
MessageId messageID)
|
boolean |
isBatchStatments()
|
void |
setBatchStatments(boolean batchStatments)
|
protected void |
setBinaryData(java.sql.PreparedStatement s,
int index,
byte[] data)
|
void |
setMaxRows(int maxRows)
|
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)
throws java.sql.SQLException,
java.io.IOException
- 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)
throws java.sql.SQLException,
java.io.IOException
- 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,
java.lang.String clientId,
java.lang.String subscriptionName,
long seq,
long prio)
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,
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
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)
- 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
doGetNextDurableSubscriberMessageStatement
public byte[] doGetNextDurableSubscriberMessageStatement(TransactionContext c,
ActiveMQDestination destination,
java.lang.String clientId,
java.lang.String subscriberName)
throws java.sql.SQLException,
java.io.IOException
- Parameters:
c
- destination
- clientId
- subscriberName
-
- Returns:
-
- 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
Copyright © 2005-2016. All Rights Reserved.