public class JDBCPersistenceAdapter extends DataSourceSupport implements PersistenceAdapter, BrokerServiceAware
PersistenceAdapter implementation using JDBC for persistence
storage.
This persistence adapter will correctly remember prepared XA transactions,
but it will not keep track of local transaction commits so that operations
performed against the Message store are done as a single uow.| Modifier and Type | Field and Description |
|---|---|
protected ActiveMQMessageAudit |
audit |
protected int |
auditRecoveryDepth |
protected boolean |
enableAudit |
protected int |
maxAuditDepth |
protected int |
maxProducersToAudit |
protected int |
maxRows |
protected LongSequenceGenerator |
sequenceGenerator |
| Constructor and Description |
|---|
JDBCPersistenceAdapter() |
JDBCPersistenceAdapter(DataSource ds,
WireFormat wireFormat) |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTransaction(ConnectionContext context)
This method starts a transaction on the persistent storage - which is nothing to
do with JMS or XA transactions - its purely a mechanism to perform multiple writes
to a persistent store in 1 transaction as a performance optimization.
|
void |
checkpoint(boolean sync)
checkpoint any
|
void |
cleanup() |
void |
commitTransaction(ConnectionContext context)
Commit a persistence transaction
|
protected JDBCAdapter |
createAdapter() |
protected void |
createMessageAudit() |
MessageStore |
createQueueMessageStore(ActiveMQQueue destination)
Factory method to create a new queue message store with the given destination name
|
TopicMessageStore |
createTopicMessageStore(ActiveMQTopic destination)
Factory method to create a new topic message store with the given destination name
|
TransactionStore |
createTransactionStore()
Factory method to create a new persistent prepared transaction store for XA recovery
|
protected void |
databaseLockKeepAlive() |
void |
deleteAllMessages()
Delete's all the messages in the persistent store.
|
JDBCAdapter |
getAdapter() |
int |
getAuditRecoveryDepth() |
BrokerService |
getBrokerService() |
int |
getCleanupPeriod() |
DatabaseLocker |
getDatabaseLocker() |
Set<ActiveMQDestination> |
getDestinations()
Returns a set of all the
ActiveMQDestination
objects that the persistence store is aware exist. |
File |
getDirectory() |
long |
getLastMessageBrokerSequenceId() |
long |
getLastProducerSequenceId(ProducerId id)
return the last stored producer sequenceId for this producer Id
used to suppress duplicate sends on failover reconnect at the transport
when a reconnect occurs
|
long |
getLockAcquireSleepInterval() |
DataSource |
getLockDataSource() |
long |
getLockKeepAlivePeriod() |
int |
getMaxAuditDepth() |
int |
getMaxProducersToAudit() |
int |
getMaxRows() |
long |
getNextSequenceId() |
ScheduledThreadPoolExecutor |
getScheduledThreadPoolExecutor() |
Statements |
getStatements() |
TransactionContext |
getTransactionContext() |
TransactionContext |
getTransactionContext(ConnectionContext context) |
WireFormat |
getWireFormat() |
void |
initSequenceIdGenerator() |
boolean |
isCreateTablesOnStartup() |
boolean |
isEnableAudit() |
boolean |
isUseDatabaseLock() |
boolean |
isUseExternalMessageReferences() |
protected DatabaseLocker |
loadDataBaseLocker() |
static void |
log(String msg,
SQLException e) |
void |
removeQueueMessageStore(ActiveMQQueue destination)
Cleanup method to remove any state associated with the given destination
|
void |
removeTopicMessageStore(ActiveMQTopic destination)
Cleanup method to remove any state associated with the given destination
No state retained....
|
void |
rollbackTransaction(ConnectionContext context)
Rollback a persistence transaction
|
void |
setAdapter(JDBCAdapter adapter) |
void |
setAuditRecoveryDepth(int auditRecoveryDepth) |
void |
setBrokerName(String brokerName)
Set the name of the broker using the adapter
|
void |
setBrokerService(BrokerService brokerService) |
void |
setCleanupPeriod(int cleanupPeriod)
Sets the number of milliseconds until the database is attempted to be
cleaned up for durable topics
|
void |
setCreateTablesOnStartup(boolean createTablesOnStartup)
Sets whether or not tables are created on startup
|
void |
setDatabaseLocker(DatabaseLocker locker)
Sets the database locker strategy to use to lock the database on startup
|
void |
setDirectory(File dir)
Set the directory where any data files should be created
|
void |
setEnableAudit(boolean enableAudit) |
void |
setLockAcquireSleepInterval(long lockAcquireSleepInterval)
millisecond interval between lock acquire attempts, applied to newly created DefaultDatabaseLocker
not applied if DataBaseLocker is injected.
|
void |
setLockDataSource(DataSource dataSource) |
void |
setLockKeepAlivePeriod(long lockKeepAlivePeriod) |
void |
setMaxAuditDepth(int maxAuditDepth) |
void |
setMaxProducersToAudit(int maxProducersToAudit) |
void |
setMaxRows(int maxRows) |
void |
setScheduledThreadPoolExecutor(ScheduledThreadPoolExecutor clockDaemon) |
void |
setStatements(Statements statements) |
void |
setTransactionIsolation(int transactionIsolation)
set the Transaction isolation level to something other that TRANSACTION_READ_UNCOMMITTED
This allowable dirty isolation level may not be achievable in clustered DB environments
so a more restrictive and expensive option may be needed like TRANSACTION_REPEATABLE_READ
see isolation level constants in
Connection |
void |
setUsageManager(SystemUsage usageManager) |
void |
setUseDatabaseLock(boolean useDatabaseLock)
Sets whether or not an exclusive database lock should be used to enable
JDBC Master/Slave.
|
void |
setUseExternalMessageReferences(boolean useExternalMessageReferences) |
void |
setWireFormat(WireFormat wireFormat) |
long |
size()
A hint to return the size of the store on disk
|
void |
start() |
void |
stop() |
protected void |
stopBroker() |
String |
toString() |
createDataSource, getDataDirectory, getDataDirectoryFile, getDataSource, setDataDirectory, setDataDirectoryFile, setDataSourceprotected int maxProducersToAudit
protected int maxAuditDepth
protected boolean enableAudit
protected int auditRecoveryDepth
protected ActiveMQMessageAudit audit
protected LongSequenceGenerator sequenceGenerator
protected int maxRows
public JDBCPersistenceAdapter()
public JDBCPersistenceAdapter(DataSource ds, WireFormat wireFormat)
public Set<ActiveMQDestination> getDestinations()
PersistenceAdapterActiveMQDestination
objects that the persistence store is aware exist.getDestinations in interface PersistenceAdapterprotected void createMessageAudit()
public void initSequenceIdGenerator()
public MessageStore createQueueMessageStore(ActiveMQQueue destination) throws IOException
PersistenceAdaptercreateQueueMessageStore in interface PersistenceAdapterIOExceptionpublic TopicMessageStore createTopicMessageStore(ActiveMQTopic destination) throws IOException
PersistenceAdaptercreateTopicMessageStore in interface PersistenceAdapterIOExceptionpublic void removeQueueMessageStore(ActiveMQQueue destination)
removeQueueMessageStore in interface PersistenceAdapterdestination - Destination to forgetpublic void removeTopicMessageStore(ActiveMQTopic destination)
removeTopicMessageStore in interface PersistenceAdapterdestination - Destination to forgetpublic TransactionStore createTransactionStore() throws IOException
PersistenceAdaptercreateTransactionStore in interface PersistenceAdapterIOExceptionpublic long getLastMessageBrokerSequenceId() throws IOException
getLastMessageBrokerSequenceId in interface PersistenceAdapterIOExceptionpublic long getLastProducerSequenceId(ProducerId id) throws IOException
PersistenceAdaptergetLastProducerSequenceId in interface PersistenceAdapterid - the producerId to find a sequenceId forIOExceptionpublic void cleanup()
public void setScheduledThreadPoolExecutor(ScheduledThreadPoolExecutor clockDaemon)
public ScheduledThreadPoolExecutor getScheduledThreadPoolExecutor()
public JDBCAdapter getAdapter() throws IOException
IOExceptionpublic DatabaseLocker getDatabaseLocker() throws IOException
IOExceptionpublic void setDatabaseLocker(DatabaseLocker locker) throws IOException
IOExceptionpublic DataSource getLockDataSource() throws IOException
IOExceptionpublic void setLockDataSource(DataSource dataSource)
public BrokerService getBrokerService()
public void setBrokerService(BrokerService brokerService)
setBrokerService in interface BrokerServiceAwareprotected JDBCAdapter createAdapter() throws IOException
IOExceptionpublic void setAdapter(JDBCAdapter adapter)
public WireFormat getWireFormat()
public void setWireFormat(WireFormat wireFormat)
public TransactionContext getTransactionContext(ConnectionContext context) throws IOException
IOExceptionpublic TransactionContext getTransactionContext() throws IOException
IOExceptionpublic void beginTransaction(ConnectionContext context) throws IOException
PersistenceAdapterbeginTransaction in interface PersistenceAdapterIOExceptionpublic void commitTransaction(ConnectionContext context) throws IOException
PersistenceAdaptercommitTransaction in interface PersistenceAdapterIOExceptionPersistenceAdapter.beginTransaction(ConnectionContext context)public void rollbackTransaction(ConnectionContext context) throws IOException
PersistenceAdapterrollbackTransaction in interface PersistenceAdapterIOExceptionPersistenceAdapter.beginTransaction(ConnectionContext context)public int getCleanupPeriod()
public void setCleanupPeriod(int cleanupPeriod)
public void deleteAllMessages() throws IOException
PersistenceAdapterdeleteAllMessages in interface PersistenceAdapterIOExceptionpublic boolean isUseExternalMessageReferences()
public void setUseExternalMessageReferences(boolean useExternalMessageReferences)
public boolean isCreateTablesOnStartup()
public void setCreateTablesOnStartup(boolean createTablesOnStartup)
public boolean isUseDatabaseLock()
public void setUseDatabaseLock(boolean useDatabaseLock)
public static void log(String msg, SQLException e)
public Statements getStatements()
public void setStatements(Statements statements)
public void setUsageManager(SystemUsage usageManager)
setUsageManager in interface PersistenceAdapterusageManager - The UsageManager that is controlling the
destination's memory usage.protected void databaseLockKeepAlive()
protected void stopBroker()
protected DatabaseLocker loadDataBaseLocker() throws IOException
IOExceptionpublic void setBrokerName(String brokerName)
PersistenceAdaptersetBrokerName in interface PersistenceAdapterpublic String toString()
toString in class DataSourceSupportpublic void setDirectory(File dir)
PersistenceAdaptersetDirectory in interface PersistenceAdapterpublic File getDirectory()
getDirectory in interface PersistenceAdapterpublic void checkpoint(boolean sync) throws IOException
PersistenceAdaptercheckpoint in interface PersistenceAdapterIOExceptionpublic long size()
PersistenceAdaptersize in interface PersistenceAdapterpublic long getLockKeepAlivePeriod()
public void setLockKeepAlivePeriod(long lockKeepAlivePeriod)
public long getLockAcquireSleepInterval()
public void setLockAcquireSleepInterval(long lockAcquireSleepInterval)
public void setTransactionIsolation(int transactionIsolation)
ConnectiontransactionIsolation - the isolation level to usepublic int getMaxProducersToAudit()
public void setMaxProducersToAudit(int maxProducersToAudit)
public int getMaxAuditDepth()
public void setMaxAuditDepth(int maxAuditDepth)
public boolean isEnableAudit()
public void setEnableAudit(boolean enableAudit)
public int getAuditRecoveryDepth()
public void setAuditRecoveryDepth(int auditRecoveryDepth)
public long getNextSequenceId()
public int getMaxRows()
public void setMaxRows(int maxRows)
Copyright © 2005–2017. All rights reserved.