org.activemq.store.cache
Class CachePersistenceAdapter

java.lang.Object
  extended by org.activemq.store.cache.CachePersistenceAdapter
All Implemented Interfaces:
Service, PersistenceAdapter
Direct Known Subclasses:
MemoryBoundedCachePersistenceAdapter, SimpleCachePersistenceAdapter

public abstract class CachePersistenceAdapter
extends Object
implements PersistenceAdapter

Implements a PersistenceAdapter designed to to speed up access to recently added messages by using a MessageCache .

Version:
$Revision: 1.1.1.1 $

Constructor Summary
CachePersistenceAdapter()
           
CachePersistenceAdapter(PersistenceAdapter longTermPersistence)
           
 
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 commitTransaction()
          Commit a persistence transaction
protected abstract  MessageCache createMessageCache(String destinationName)
          Subclasses should override this method to change the type of MessageCache that is used to cache messages.
 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 useLocking)
          Verifies if a dead letter has already been sent for a message
 Map getInitialDestinations()
          Returns a map, indexed by String name, of all the Destination objects active on startup.
 PersistenceAdapter getLongTermPersistence()
           
 void rollbackTransaction()
          Rollback a persistence transaction
 void setLongTermPersistence(PersistenceAdapter longTermPersistence)
           
 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

CachePersistenceAdapter

public CachePersistenceAdapter()

CachePersistenceAdapter

public CachePersistenceAdapter(PersistenceAdapter longTermPersistence)
                        throws IOException
Throws:
IOException
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

stop

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

Specified by:
stop in interface Service
Throws:
JMSException

deadLetterAlreadySent

public boolean deadLetterAlreadySent(long seq,
                                     boolean useLocking)
Verifies if a dead letter has already been sent for a message

Specified by:
deadLetterAlreadySent in interface PersistenceAdapter
Parameters:
seq -
useLocking - to prevent concurrency/dups
Returns:

getLongTermPersistence

public PersistenceAdapter getLongTermPersistence()

setLongTermPersistence

public void setLongTermPersistence(PersistenceAdapter longTermPersistence)

createMessageCache

protected abstract MessageCache createMessageCache(String destinationName)
Subclasses should override this method to change the type of MessageCache that is used to cache messages.

Parameters:
destinationName -
Returns:


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