public class JDBCPersistenceAdapter extends DataSourceServiceSupport implements PersistenceAdapter
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 org.apache.activemq.ActiveMQMessageAudit |
audit |
protected int |
auditRecoveryDepth |
static long |
DEFAULT_LOCK_KEEP_ALIVE_PERIOD |
protected boolean |
enableAudit |
protected int |
maxAuditDepth |
protected int |
maxProducersToAudit |
protected int |
maxRows |
protected LongSequenceGenerator |
sequenceGenerator |
brokerService| Constructor and Description |
|---|
JDBCPersistenceAdapter() |
JDBCPersistenceAdapter(DataSource ds,
org.apache.activemq.wireformat.WireFormat wireFormat) |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTransaction(ConnectionContext context) |
void |
checkpoint(boolean sync) |
void |
cleanup() |
void |
commitAdd(ConnectionContext context,
org.apache.activemq.command.MessageId messageId) |
void |
commitLastAck(ConnectionContext context,
long xidLastAck,
long priority,
org.apache.activemq.command.ActiveMQDestination destination,
String subName,
String clientId) |
void |
commitRemove(ConnectionContext context,
org.apache.activemq.command.MessageAck ack) |
void |
commitTransaction(ConnectionContext context) |
protected JDBCAdapter |
createAdapter() |
Locker |
createDefaultLocker() |
protected void |
createMessageAudit() |
MessageStore |
createQueueMessageStore(org.apache.activemq.command.ActiveMQQueue destination) |
TopicMessageStore |
createTopicMessageStore(org.apache.activemq.command.ActiveMQTopic destination) |
TransactionStore |
createTransactionStore() |
void |
deleteAllMessages() |
void |
doStart() |
void |
doStop(ServiceStopper stopper) |
JDBCAdapter |
getAdapter() |
int |
getAuditRecoveryDepth() |
BrokerService |
getBrokerService() |
int |
getCleanupPeriod() |
Locker |
getDatabaseLocker()
Deprecated.
as of 5.7.0, replaced by
LockableServiceSupport.getLocker() |
Set<org.apache.activemq.command.ActiveMQDestination> |
getDestinations() |
File |
getDirectory() |
long |
getLastMessageBrokerSequenceId() |
long |
getLastProducerSequenceId(org.apache.activemq.command.ProducerId id) |
DataSource |
getLockDataSource() |
int |
getMaxAuditDepth() |
int |
getMaxProducersToAudit() |
int |
getMaxRows() |
long |
getNextSequenceId() |
ScheduledThreadPoolExecutor |
getScheduledThreadPoolExecutor() |
Statements |
getStatements() |
TransactionContext |
getTransactionContext() |
TransactionContext |
getTransactionContext(ConnectionContext context) |
org.apache.activemq.wireformat.WireFormat |
getWireFormat() |
void |
init() |
void |
initSequenceIdGenerator() |
boolean |
isChangeAutoCommitAllowed() |
boolean |
isCreateTablesOnStartup() |
boolean |
isEnableAudit() |
boolean |
isUseExternalMessageReferences() |
static void |
log(String msg,
SQLException e) |
void |
recover(JdbcMemoryTransactionStore jdbcMemoryTransactionStore) |
void |
removeQueueMessageStore(org.apache.activemq.command.ActiveMQQueue destination)
Cleanup method to remove any state associated with the given destination
|
void |
removeTopicMessageStore(org.apache.activemq.command.ActiveMQTopic destination)
Cleanup method to remove any state associated with the given destination
No state retained....
|
void |
rollbackLastAck(ConnectionContext context,
byte priority,
org.apache.activemq.command.ActiveMQDestination destination,
String subName,
String clientId) |
void |
rollbackLastAck(ConnectionContext context,
JDBCTopicMessageStore store,
org.apache.activemq.command.MessageAck ack,
String subName,
String clientId) |
void |
rollbackTransaction(ConnectionContext context) |
void |
setAdapter(JDBCAdapter adapter) |
void |
setAuditRecoveryDepth(int auditRecoveryDepth) |
void |
setBrokerName(String brokerName) |
void |
setChangeAutoCommitAllowed(boolean changeAutoCommitAllowed)
Whether the JDBC driver allows to set the auto commit.
|
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(Locker locker)
Deprecated.
as of 5.7.0, replaced by
LockableServiceSupport.setLocker(org.apache.activemq.broker.Locker) |
void |
setDirectory(File dir) |
void |
setEnableAudit(boolean enableAudit) |
void |
setLockAcquireSleepInterval(long lockAcquireSleepInterval)
Deprecated.
use
Locker.setLockAcquireSleepInterval(long) instead
millisecond interval between lock acquire attempts, applied to newly created DefaultDatabaseLocker
not applied if DataBaseLocker is injected. |
void |
setLockDataSource(DataSource dataSource) |
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)
Deprecated.
use
LockableServiceSupport.setUseLock(boolean) instead
Sets whether or not an exclusive database lock should be used to enable
JDBC Master/Slave. Enabled by default. |
void |
setUseExternalMessageReferences(boolean useExternalMessageReferences) |
void |
setWireFormat(org.apache.activemq.wireformat.WireFormat wireFormat) |
long |
size() |
String |
toString() |
createDataSource, getDataDirectory, getDataDirectoryFile, getDataSource, setDataDirectory, setDataDirectoryFile, setDataSourcegetLocker, getLockKeepAlivePeriod, isUseLock, keepLockAlive, postStop, preStart, setBrokerService, setLocker, setLockKeepAlivePeriod, setUseLock, stopBrokeraddServiceListener, dispose, isStarted, isStopped, isStopping, removeServiceListener, start, stoppublic static final long DEFAULT_LOCK_KEEP_ALIVE_PERIOD
protected int maxProducersToAudit
protected int maxAuditDepth
protected boolean enableAudit
protected int auditRecoveryDepth
protected org.apache.activemq.ActiveMQMessageAudit audit
protected LongSequenceGenerator sequenceGenerator
protected int maxRows
public JDBCPersistenceAdapter()
public JDBCPersistenceAdapter(DataSource ds, org.apache.activemq.wireformat.WireFormat wireFormat)
public Set<org.apache.activemq.command.ActiveMQDestination> getDestinations()
getDestinations in interface PersistenceAdapterprotected void createMessageAudit()
public void initSequenceIdGenerator()
public MessageStore createQueueMessageStore(org.apache.activemq.command.ActiveMQQueue destination) throws IOException
createQueueMessageStore in interface PersistenceAdapterIOExceptionpublic TopicMessageStore createTopicMessageStore(org.apache.activemq.command.ActiveMQTopic destination) throws IOException
createTopicMessageStore in interface PersistenceAdapterIOExceptionpublic void removeQueueMessageStore(org.apache.activemq.command.ActiveMQQueue destination)
removeQueueMessageStore in interface PersistenceAdapterdestination - Destination to forgetpublic void removeTopicMessageStore(org.apache.activemq.command.ActiveMQTopic destination)
removeTopicMessageStore in interface PersistenceAdapterdestination - Destination to forgetpublic TransactionStore createTransactionStore() throws IOException
createTransactionStore in interface PersistenceAdapterIOExceptionpublic long getLastMessageBrokerSequenceId()
throws IOException
getLastMessageBrokerSequenceId in interface PersistenceAdapterIOExceptionpublic long getLastProducerSequenceId(org.apache.activemq.command.ProducerId id)
throws IOException
getLastProducerSequenceId in interface PersistenceAdapterIOExceptionpublic void init()
throws Exception
init in class LockableServiceSupportExceptionpublic void doStart()
throws Exception
doStart in class ServiceSupportExceptionpublic void doStop(ServiceStopper stopper) throws Exception
doStop in class ServiceSupportExceptionpublic void cleanup()
public void setScheduledThreadPoolExecutor(ScheduledThreadPoolExecutor clockDaemon)
public ScheduledThreadPoolExecutor getScheduledThreadPoolExecutor()
getScheduledThreadPoolExecutor in class LockableServiceSupportpublic JDBCAdapter getAdapter() throws IOException
IOException@Deprecated public Locker getDatabaseLocker() throws IOException
LockableServiceSupport.getLocker()IOException@Deprecated public void setDatabaseLocker(Locker locker) throws IOException
LockableServiceSupport.setLocker(org.apache.activemq.broker.Locker)IOExceptionpublic DataSource getLockDataSource() throws IOException
IOExceptionpublic void setLockDataSource(DataSource dataSource)
public BrokerService getBrokerService()
getBrokerService in class LockableServiceSupportprotected JDBCAdapter createAdapter() throws IOException
IOExceptionpublic void setAdapter(JDBCAdapter adapter)
public org.apache.activemq.wireformat.WireFormat getWireFormat()
public void setWireFormat(org.apache.activemq.wireformat.WireFormat wireFormat)
public TransactionContext getTransactionContext(ConnectionContext context) throws IOException
IOExceptionpublic TransactionContext getTransactionContext() throws IOException
IOExceptionpublic void beginTransaction(ConnectionContext context) throws IOException
beginTransaction in interface PersistenceAdapterIOExceptionpublic void commitTransaction(ConnectionContext context) throws IOException
commitTransaction in interface PersistenceAdapterIOExceptionpublic void rollbackTransaction(ConnectionContext context) throws IOException
rollbackTransaction in interface PersistenceAdapterIOExceptionpublic int getCleanupPeriod()
public void setCleanupPeriod(int cleanupPeriod)
public boolean isChangeAutoCommitAllowed()
public void setChangeAutoCommitAllowed(boolean changeAutoCommitAllowed)
changeAutoCommitAllowed - true to change, false to not change.public void deleteAllMessages()
throws IOException
deleteAllMessages in interface PersistenceAdapterIOExceptionpublic boolean isUseExternalMessageReferences()
public void setUseExternalMessageReferences(boolean useExternalMessageReferences)
public boolean isCreateTablesOnStartup()
public void setCreateTablesOnStartup(boolean createTablesOnStartup)
@Deprecated public void setUseDatabaseLock(boolean useDatabaseLock)
LockableServiceSupport.setUseLock(boolean) instead
Sets whether or not an exclusive database lock should be used to enable
JDBC Master/Slave. Enabled by default.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.public Locker createDefaultLocker() throws IOException
createDefaultLocker in interface LockableIOExceptionpublic void setBrokerName(String brokerName)
setBrokerName in interface PersistenceAdapterpublic String toString()
toString in class DataSourceServiceSupportpublic void setDirectory(File dir)
setDirectory in interface PersistenceAdapterpublic File getDirectory()
getDirectory in interface PersistenceAdapterpublic void checkpoint(boolean sync)
throws IOException
checkpoint in interface PersistenceAdapterIOExceptionpublic long size()
size in interface PersistenceAdapter@Deprecated public void setLockAcquireSleepInterval(long lockAcquireSleepInterval) throws IOException
Locker.setLockAcquireSleepInterval(long) instead
millisecond interval between lock acquire attempts, applied to newly created DefaultDatabaseLocker
not applied if DataBaseLocker is injected.IOExceptionpublic 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)
public void recover(JdbcMemoryTransactionStore jdbcMemoryTransactionStore) throws IOException
IOExceptionpublic void commitAdd(ConnectionContext context, org.apache.activemq.command.MessageId messageId) throws IOException
IOExceptionpublic void commitRemove(ConnectionContext context, org.apache.activemq.command.MessageAck ack) throws IOException
IOExceptionpublic void commitLastAck(ConnectionContext context, long xidLastAck, long priority, org.apache.activemq.command.ActiveMQDestination destination, String subName, String clientId) throws IOException
IOExceptionpublic void rollbackLastAck(ConnectionContext context, JDBCTopicMessageStore store, org.apache.activemq.command.MessageAck ack, String subName, String clientId) throws IOException
IOExceptionpublic void rollbackLastAck(ConnectionContext context, byte priority, org.apache.activemq.command.ActiveMQDestination destination, String subName, String clientId) throws IOException
IOExceptionCopyright © 2005-2015 The Apache Software Foundation. All Rights Reserved.