org.activemq.store.jdbc
Class JDBCPersistenceAdapter

java.lang.Object
  extended by org.activemq.store.jdbc.JDBCPersistenceAdapter
All Implemented Interfaces:
Service, PersistenceAdapter

public class JDBCPersistenceAdapter
extends Object
implements PersistenceAdapter

A 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.

Version:
$Revision: 1.1 $

Constructor Summary
JDBCPersistenceAdapter()
           
JDBCPersistenceAdapter(DataSource ds, WireFormat wireFormat)
           
 
Method Summary
 void beginTransaction()
          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 optimisation.
 void cleanup()
           
 void cleanupOldMessage(Connection c, MessageIdentity messageIdentity)
           
 void commitTransaction()
          Commit a persistence transaction
 MessageStore createQueueMessageStore(String destinationName)
          Factory method to create a new queue message store with the given destination name
 TopicMessageStore createTopicMessageStore(String destinationName)
          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
 boolean deadLetterAlreadySent(long seq, boolean useDatabaseLocking)
          Ensures that no previous dead letter was already sent for this message
 String getAdapterClass()
           
 BrokerContainer getBrokerContainer()
           
 int getCleanupPeriod()
           
 long getCleanupRepeatInterval()
           
 ClockDaemon getClockDaemon()
           
 Connection getConnection()
           
 DataSource getDataSource()
           
 DeadLetterPolicy getDeadLetterPolicy()
           
 boolean getDeleteExpiredMessages()
           
 boolean getDropTablesOnStartup()
           
 Map getInitialDestinations()
          Returns a map, indexed by String name, of all the Destination objects active on startup.
 JDBCAdapter getJDBCAdapter()
           
 String getTablePrefix()
           
 WireFormat getWireFormat()
           
 boolean isAutoCleanupExpiredMessages()
           
 void returnConnection(Connection connection)
           
 void rollbackTransaction()
          Rollback a persistence transaction
protected  void sendToDeadLetter(ActiveMQMessage message)
           
 void setAdapterClass(String adapterClass)
           
 void setAutoCleanupExpiredMessages(boolean autoCleanupExpiredMessages)
           
 void setBrokerContainer(BrokerContainer brokerContainer)
           
 void setCleanupPeriod(int cleanupPeriod)
           
 void setCleanupRepeatInterval(long cleanupRepeatInterval)
           
 void setClockDaemon(ClockDaemon clockDaemon)
           
 void setDataSource(DataSource dataSource)
           
 void setDeadLetterPolicy(DeadLetterPolicy deadLetterPolicy)
           
 void setDeleteExpiredMessages(boolean deleteExpiredMessages)
           
 void setDropTablesOnStartup(boolean dropTablesOnStartup)
           
 void setTablePrefix(String tablePrefix)
           
 void setWireFormat(WireFormat wireFormat)
           
 void start()
          Called to start the service
 void stop()
          Called to shutdown the service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCPersistenceAdapter

public JDBCPersistenceAdapter()

JDBCPersistenceAdapter

public JDBCPersistenceAdapter(DataSource ds,
                              WireFormat wireFormat)
Method Detail

getInitialDestinations

public Map getInitialDestinations()
Description copied from interface: PersistenceAdapter
Returns a map, indexed by String name, of all the Destination objects active on startup.

Specified by:
getInitialDestinations in interface PersistenceAdapter
Returns:

createQueueMessageStore

public MessageStore createQueueMessageStore(String destinationName)
                                     throws JMSException
Description copied from interface: PersistenceAdapter
Factory method to create a new queue message store with the given destination name

Specified by:
createQueueMessageStore in interface PersistenceAdapter
Throws:
JMSException

createTopicMessageStore

public TopicMessageStore createTopicMessageStore(String destinationName)
                                          throws JMSException
Description copied from interface: PersistenceAdapter
Factory method to create a new topic message store with the given destination name

Specified by:
createTopicMessageStore in interface PersistenceAdapter
Throws:
JMSException

createTransactionStore

public TransactionStore createTransactionStore()
                                        throws JMSException
Description copied from interface: PersistenceAdapter
Factory method to create a new persistent prepared transaction store for XA recovery

Specified by:
createTransactionStore in interface PersistenceAdapter
Throws:
JMSException

beginTransaction

public void beginTransaction()
                      throws JMSException
Description copied from interface: PersistenceAdapter
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 optimisation.

Typically one transaction will require one disk synchronization point and so for real high performance its usually faster to perform many writes within the same transaction to minimise latency caused by disk synchronization. This is especially true when using tools like Berkeley Db or embedded JDBC servers.

Specified by:
beginTransaction in interface PersistenceAdapter
Throws:
JMSException

commitTransaction

public void commitTransaction()
                       throws JMSException
Description copied from interface: PersistenceAdapter
Commit a persistence transaction

Specified by:
commitTransaction in interface PersistenceAdapter
Throws:
JMSException
See Also:
PersistenceAdapter.beginTransaction()

rollbackTransaction

public void rollbackTransaction()
Description copied from interface: PersistenceAdapter
Rollback a persistence transaction

Specified by:
rollbackTransaction in interface PersistenceAdapter
See Also:
PersistenceAdapter.beginTransaction()

start

public void start()
           throws JMSException
Description copied from interface: Service
Called to start the service

Specified by:
start in interface Service
Throws:
JMSException

cleanup

public void cleanup()
             throws SQLException
Throws:
SQLException

sendToDeadLetter

protected void sendToDeadLetter(ActiveMQMessage message)
                         throws JMSException
Throws:
JMSException

cleanupOldMessage

public void cleanupOldMessage(Connection c,
                              MessageIdentity messageIdentity)
                       throws JMSException,
                              SQLException
Throws:
JMSException
SQLException

deadLetterAlreadySent

public boolean deadLetterAlreadySent(long seq,
                                     boolean useDatabaseLocking)
Ensures that no previous dead letter was already sent for this message

Specified by:
deadLetterAlreadySent in interface PersistenceAdapter
useDatabaseLocking - to prevent concurrency/dups
Returns:

setClockDaemon

public void setClockDaemon(ClockDaemon clockDaemon)

getClockDaemon

public ClockDaemon getClockDaemon()

stop

public void stop()
          throws JMSException
Description copied from interface: Service
Called to shutdown the service

Specified by:
stop in interface Service
Throws:
JMSException

getBrokerContainer

public BrokerContainer getBrokerContainer()

setBrokerContainer

public void setBrokerContainer(BrokerContainer brokerContainer)

getDataSource

public DataSource getDataSource()

setDataSource

public void setDataSource(DataSource dataSource)

getWireFormat

public WireFormat getWireFormat()

setWireFormat

public void setWireFormat(WireFormat wireFormat)

getConnection

public Connection getConnection()
                         throws SQLException
Throws:
SQLException

returnConnection

public void returnConnection(Connection connection)

getAdapterClass

public String getAdapterClass()
Returns:
Returns the adapterClass.

setAdapterClass

public void setAdapterClass(String adapterClass)
Parameters:
adapterClass - The adapterClass to set.

getJDBCAdapter

public JDBCAdapter getJDBCAdapter()

getDropTablesOnStartup

public boolean getDropTablesOnStartup()
Returns:
Returns the dropTablesOnStartup.

setDropTablesOnStartup

public void setDropTablesOnStartup(boolean dropTablesOnStartup)
Parameters:
dropTablesOnStartup - The dropTablesOnStartup to set.

getDeadLetterPolicy

public DeadLetterPolicy getDeadLetterPolicy()

setDeadLetterPolicy

public void setDeadLetterPolicy(DeadLetterPolicy deadLetterPolicy)

getDeleteExpiredMessages

public boolean getDeleteExpiredMessages()

setDeleteExpiredMessages

public void setDeleteExpiredMessages(boolean deleteExpiredMessages)

isAutoCleanupExpiredMessages

public boolean isAutoCleanupExpiredMessages()
Returns:
Returns the autoCleanupExpiredMessages.

setAutoCleanupExpiredMessages

public void setAutoCleanupExpiredMessages(boolean autoCleanupExpiredMessages)
Parameters:
autoCleanupExpiredMessages - The autoCleanupExpiredMessages to set.

getCleanupRepeatInterval

public long getCleanupRepeatInterval()
Returns:
Returns the cleanupRepeatInterval.

setCleanupRepeatInterval

public void setCleanupRepeatInterval(long cleanupRepeatInterval)
Parameters:
cleanupRepeatInterval - The cleanupRepeatInterval to set.

getCleanupPeriod

public int getCleanupPeriod()

setCleanupPeriod

public void setCleanupPeriod(int cleanupPeriod)

getTablePrefix

public String getTablePrefix()

setTablePrefix

public void setTablePrefix(String tablePrefix)


Copyright © 2004-2010 Protique, Ltd.. All Rights Reserved.