org.apache.activemq.store.rapid
Class RapidMessageStore

java.lang.Object
  extended by org.apache.activemq.store.rapid.RapidMessageStore
All Implemented Interfaces:
Service, MessageStore
Direct Known Subclasses:
RapidTopicMessageStore

public class RapidMessageStore
extends java.lang.Object
implements MessageStore

A MessageStore that uses a Journal to store it's messages.

Version:
$Revision: 1.14 $

Field Summary
protected  ActiveMQDestination destination
           
protected  java.util.HashSet inFlightTxLocations
           
protected  org.apache.activeio.journal.RecordLocation lastLocation
           
protected  MapContainer messageContainer
           
protected  RapidPersistenceAdapter peristenceAdapter
           
protected  RapidTransactionStore transactionStore
           
protected  TransactionTemplate transactionTemplate
           
 
Constructor Summary
RapidMessageStore(RapidPersistenceAdapter adapter, ActiveMQDestination destination, MapContainer container)
           
 
Method Summary
 void addMessage(ConnectionContext context, Message message)
          Not synchronized since the Journal has better throughput if you increase the number of concurrent writes that it is doing.
 void addMessageReference(ConnectionContext context, MessageId messageId, long expirationTime, java.lang.String messageRef)
          Adds a message reference to the message store
 org.apache.activeio.journal.RecordLocation checkpoint()
           
 ActiveMQDestination getDestination()
          The destination that the message store is holding messages for.
 Message getMessage(MessageId id)
          Looks up a message using either the String messageID or the messageNumber.
 java.lang.String getMessageReference(MessageId identity)
          Looks up a message using either the String messageID or the messageNumber.
 void recover(MessageRecoveryListener listener)
          Replays the checkpointStore first as those messages are the oldest ones, then messages are replayed from the transaction log and then the cache is updated.
 void removeAllMessages(ConnectionContext context)
          Removes all the messages from the message store.
 void removeMessage(ConnectionContext context, MessageAck ack)
          Removes a message from the message store.
 void replayAddMessage(ConnectionContext context, Message message, org.apache.activeio.journal.RecordLocation location)
           
 void replayRemoveMessage(ConnectionContext context, MessageAck ack)
           
 void setUsageManager(UsageManager usageManager)
           
 void start()
           
 void stop()
           
protected static org.apache.activeio.journal.RecordLocation toRecordLocation(java.lang.String t)
           
protected static java.lang.String toString(org.apache.activeio.journal.RecordLocation location)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

peristenceAdapter

protected final RapidPersistenceAdapter peristenceAdapter

transactionStore

protected final RapidTransactionStore transactionStore

messageContainer

protected final MapContainer messageContainer

destination

protected final ActiveMQDestination destination

transactionTemplate

protected final TransactionTemplate transactionTemplate

lastLocation

protected org.apache.activeio.journal.RecordLocation lastLocation

inFlightTxLocations

protected java.util.HashSet inFlightTxLocations
Constructor Detail

RapidMessageStore

public RapidMessageStore(RapidPersistenceAdapter adapter,
                         ActiveMQDestination destination,
                         MapContainer container)
Method Detail

addMessage

public void addMessage(ConnectionContext context,
                       Message message)
                throws java.io.IOException
Not synchronized since the Journal has better throughput if you increase the number of concurrent writes that it is doing.

Specified by:
addMessage in interface MessageStore
Parameters:
context - TODO
Throws:
java.io.IOException

toString

protected static java.lang.String toString(org.apache.activeio.journal.RecordLocation location)

toRecordLocation

protected static org.apache.activeio.journal.RecordLocation toRecordLocation(java.lang.String t)

replayAddMessage

public void replayAddMessage(ConnectionContext context,
                             Message message,
                             org.apache.activeio.journal.RecordLocation location)

removeMessage

public void removeMessage(ConnectionContext context,
                          MessageAck ack)
                   throws java.io.IOException
Description copied from interface: MessageStore
Removes a message from the message store.

Specified by:
removeMessage in interface MessageStore
Parameters:
context - TODO
ack - the ack request that cause the message to be removed. It conatins the identity which contains the messageID of the message that needs to be removed.
Throws:
java.io.IOException

replayRemoveMessage

public void replayRemoveMessage(ConnectionContext context,
                                MessageAck ack)

getMessage

public Message getMessage(MessageId id)
                   throws java.io.IOException
Description copied from interface: MessageStore
Looks up a message using either the String messageID or the messageNumber. Implementations are encouraged to fill in the missing key if its easy to do so.

Specified by:
getMessage in interface MessageStore
Parameters:
id - which contains either the messageID or the messageNumber
Returns:
the message or null if it does not exist
Throws:
java.io.IOException

recover

public void recover(MessageRecoveryListener listener)
             throws java.lang.Exception
Replays the checkpointStore first as those messages are the oldest ones, then messages are replayed from the transaction log and then the cache is updated.

Specified by:
recover in interface MessageStore
Parameters:
listener -
Throws:
java.lang.Exception

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Service
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface Service
Throws:
java.lang.Exception

removeAllMessages

public void removeAllMessages(ConnectionContext context)
                       throws java.io.IOException
Description copied from interface: MessageStore
Removes all the messages from the message store.

Specified by:
removeAllMessages in interface MessageStore
Parameters:
context - TODO
Throws:
java.io.IOException
See Also:
MessageStore.removeAllMessages(ConnectionContext)

getDestination

public ActiveMQDestination getDestination()
Description copied from interface: MessageStore
The destination that the message store is holding messages for.

Specified by:
getDestination in interface MessageStore
Returns:

addMessageReference

public void addMessageReference(ConnectionContext context,
                                MessageId messageId,
                                long expirationTime,
                                java.lang.String messageRef)
                         throws java.io.IOException
Description copied from interface: MessageStore
Adds a message reference to the message store

Specified by:
addMessageReference in interface MessageStore
Parameters:
context - TODO
messageId - TODO
expirationTime - TODO
Throws:
java.io.IOException

getMessageReference

public java.lang.String getMessageReference(MessageId identity)
                                     throws java.io.IOException
Description copied from interface: MessageStore
Looks up a message using either the String messageID or the messageNumber. Implementations are encouraged to fill in the missing key if its easy to do so.

Specified by:
getMessageReference in interface MessageStore
Parameters:
identity - which contains either the messageID or the messageNumber
Returns:
the message or null if it does not exist
Throws:
java.io.IOException

setUsageManager

public void setUsageManager(UsageManager usageManager)
Specified by:
setUsageManager in interface MessageStore
Parameters:
usageManager - The UsageManager that is controlling the destination's memory usage.

checkpoint

public org.apache.activeio.journal.RecordLocation checkpoint()
                                                      throws java.io.IOException
Returns:
Throws:
java.io.IOException


Copyright © 2009 Apache Software Foundation. All Rights Reserved.