org.springframework.integration.store
Class AbstractKeyValueMessageStore

java.lang.Object
  extended by org.springframework.integration.store.AbstractMessageGroupStore
      extended by org.springframework.integration.store.AbstractKeyValueMessageStore
All Implemented Interfaces:
java.lang.Iterable<MessageGroup>, MessageGroupStore, MessageStore
Direct Known Subclasses:
GemfireMessageStore, RedisMessageStore

public abstract class AbstractKeyValueMessageStore
extends AbstractMessageGroupStore
implements MessageStore

Base class for implementations of Key/Value style MessageGroupStore and MessageStore

Since:
2.1

Field Summary
protected static java.lang.String MESSAGE_GROUP_KEY_PREFIX
           
protected static java.lang.String MESSAGE_KEY_PREFIX
           
 
Fields inherited from class org.springframework.integration.store.AbstractMessageGroupStore
logger
 
Constructor Summary
AbstractKeyValueMessageStore()
           
 
Method Summary
<T> Message<T>
addMessage(Message<T> message)
          Put the provided Message into the MessageStore.
 MessageGroup addMessageToGroup(java.lang.Object groupId, Message<?> message)
          Add a Message to the group with the provided group ID.
 void completeGroup(java.lang.Object groupId)
          Completes this MessageGroup.
protected abstract  java.util.Collection<?> doListKeys(java.lang.String keyPattern)
           
protected abstract  java.lang.Object doRemove(java.lang.Object id)
           
protected abstract  java.lang.Object doRetrieve(java.lang.Object id)
           
protected abstract  void doStore(java.lang.Object id, java.lang.Object objectToStore)
           
 Message<?> getMessage(java.util.UUID id)
          Return the Message with the given id, or null if no Message with that id exists in the MessageStore.
 long getMessageCount()
          Optional attribute giving the number of messages in the store.
 MessageGroup getMessageGroup(java.lang.Object groupId)
          Will create a new instance of SimpleMessageGroup if necessary.
 java.util.Iterator<MessageGroup> iterator()
          Returns the iterator of currently accumulated MessageGroups
 MessageGroup markMessageFromGroup(java.lang.Object groupId, Message<?> messageToMark)
          Mark the given Message within the group corresponding to the provided group ID.
 MessageGroup markMessageGroup(MessageGroup group)
          Mark all messages in the provided group.
 Message<?> removeMessage(java.util.UUID id)
          Remove the Message with the given id from the MessageStore, if present, and return it.
 MessageGroup removeMessageFromGroup(java.lang.Object groupId, Message<?> messageToRemove)
          Remove a Message from the group with the provided group ID.
 void removeMessageGroup(java.lang.Object groupId)
          Remove the MessageGroup with the provided group ID.
 void setLastReleasedSequenceNumberForGroup(java.lang.Object groupId, int sequenceNumber)
          Allows you to set the sequence number of the last released Message.
 
Methods inherited from class org.springframework.integration.store.AbstractMessageGroupStore
expireMessageGroups, getMarkedMessageCountForAllMessageGroups, getMessageCountForAllMessageGroups, getMessageGroupCount, registerMessageGroupExpiryCallback, setExpiryCallbacks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_KEY_PREFIX

protected static final java.lang.String MESSAGE_KEY_PREFIX
See Also:
Constant Field Values

MESSAGE_GROUP_KEY_PREFIX

protected static final java.lang.String MESSAGE_GROUP_KEY_PREFIX
See Also:
Constant Field Values
Constructor Detail

AbstractKeyValueMessageStore

public AbstractKeyValueMessageStore()
Method Detail

getMessage

public Message<?> getMessage(java.util.UUID id)
Description copied from interface: MessageStore
Return the Message with the given id, or null if no Message with that id exists in the MessageStore.

Specified by:
getMessage in interface MessageStore

addMessage

public <T> Message<T> addMessage(Message<T> message)
Description copied from interface: MessageStore
Put the provided Message into the MessageStore. The store may need to mutate the message internally, and if it does then the return value can be different than the input. The id of the return value will be used as an index so that the MessageStore.getMessage(UUID) and MessageStore.removeMessage(UUID) behave properly. Since messages are immutable, putting the same message more than once is a no-op.

Specified by:
addMessage in interface MessageStore
Returns:
the message that was stored

removeMessage

public Message<?> removeMessage(java.util.UUID id)
Description copied from interface: MessageStore
Remove the Message with the given id from the MessageStore, if present, and return it. If no Message with that id is present in the store, this will return null.

Specified by:
removeMessage in interface MessageStore

getMessageCount

@ManagedAttribute
public long getMessageCount()
Description copied from interface: MessageStore
Optional attribute giving the number of messages in the store. Implementations may decline to respond by throwing an exception.

Specified by:
getMessageCount in interface MessageStore
Returns:
the number of messages

getMessageGroup

public MessageGroup getMessageGroup(java.lang.Object groupId)
Will create a new instance of SimpleMessageGroup if necessary.

Specified by:
getMessageGroup in interface MessageGroupStore
Returns:
a group of messages, empty if none exists for this key

addMessageToGroup

public MessageGroup addMessageToGroup(java.lang.Object groupId,
                                      Message<?> message)
Add a Message to the group with the provided group ID.

Specified by:
addMessageToGroup in interface MessageGroupStore
Parameters:
groupId - the group id to store the message under
message - a message

markMessageGroup

public MessageGroup markMessageGroup(MessageGroup group)
Mark all messages in the provided group.

Specified by:
markMessageGroup in interface MessageGroupStore
Parameters:
group - a MessageGroup with no unmarked messages

removeMessageFromGroup

public MessageGroup removeMessageFromGroup(java.lang.Object groupId,
                                           Message<?> messageToRemove)
Remove a Message from the group with the provided group ID.

Specified by:
removeMessageFromGroup in interface MessageGroupStore
Parameters:
groupId - the groupId for the group containing the message
messageToRemove - the message to be removed

markMessageFromGroup

public MessageGroup markMessageFromGroup(java.lang.Object groupId,
                                         Message<?> messageToMark)
Mark the given Message within the group corresponding to the provided group ID.

Specified by:
markMessageFromGroup in interface MessageGroupStore
Parameters:
groupId - the groupId for the group containing the message
messageToMark - the message to be marked

completeGroup

public void completeGroup(java.lang.Object groupId)
Description copied from interface: MessageGroupStore
Completes this MessageGroup. Completion of the MessageGroup generally means that this group should not be allowing any more mutating operation to be performed on it. For example any attempt to add/remove new Message form the group should not be allowed.

Specified by:
completeGroup in interface MessageGroupStore

removeMessageGroup

public void removeMessageGroup(java.lang.Object groupId)
Remove the MessageGroup with the provided group ID.

Specified by:
removeMessageGroup in interface MessageGroupStore
Parameters:
groupId - the id of the group to remove

setLastReleasedSequenceNumberForGroup

public void setLastReleasedSequenceNumberForGroup(java.lang.Object groupId,
                                                  int sequenceNumber)
Description copied from interface: MessageGroupStore
Allows you to set the sequence number of the last released Message. Used for Resequencing use cases

Specified by:
setLastReleasedSequenceNumberForGroup in interface MessageGroupStore

iterator

public java.util.Iterator<MessageGroup> iterator()
Description copied from interface: MessageGroupStore
Returns the iterator of currently accumulated MessageGroups

Specified by:
iterator in interface java.lang.Iterable<MessageGroup>
Specified by:
iterator in interface MessageGroupStore

doRetrieve

protected abstract java.lang.Object doRetrieve(java.lang.Object id)

doStore

protected abstract void doStore(java.lang.Object id,
                                java.lang.Object objectToStore)

doRemove

protected abstract java.lang.Object doRemove(java.lang.Object id)

doListKeys

protected abstract java.util.Collection<?> doListKeys(java.lang.String keyPattern)