Spring Integration

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
Author:
Oleg Zhurakousky

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.springframework.integration.store.MessageGroupStore
MessageGroupStore.MessageGroupCallback
 
Field Summary
protected static java.lang.String CREATED_DATE
           
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
 int messageGroupSize(java.lang.Object groupId)
          Returns the size of this MessageGroup
 Message<?> pollMessageFromGroup(java.lang.Object groupId)
          Polls Message from this MessageGroup (in FIFO style if supported by the implementation) while also removing the polled Message
 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, getMessageCountForAllMessageGroups, getMessageGroupCount, isTimeoutOnIdle, registerMessageGroupExpiryCallback, setExpiryCallbacks, setTimeoutOnIdle
 
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

CREATED_DATE

protected static final java.lang.String CREATED_DATE
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

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

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

pollMessageFromGroup

public Message<?> pollMessageFromGroup(java.lang.Object groupId)
Description copied from interface: MessageGroupStore
Polls Message from this MessageGroup (in FIFO style if supported by the implementation) while also removing the polled Message

Specified by:
pollMessageFromGroup 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

messageGroupSize

public int messageGroupSize(java.lang.Object groupId)
Description copied from interface: MessageGroupStore
Returns the size of this MessageGroup

Specified by:
messageGroupSize 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)

Spring Integration