org.springframework.integration.gemfire.store
Class KeyValueMessageGroupStore

java.lang.Object
  extended by org.springframework.integration.store.AbstractMessageGroupStore
      extended by org.springframework.integration.gemfire.store.KeyValueMessageGroupStore
All Implemented Interfaces:
java.lang.Iterable<MessageGroup>, MessageGroupStore
Direct Known Subclasses:
GemfireMessageGroupStore

public class KeyValueMessageGroupStore
extends AbstractMessageGroupStore

Provides an implementation of MessageGroupStore that delegates to a backend Gemfire instance. Gemfire holds keys and values. This class provides a strategy to hold objects.

Since:
2.1

Field Summary
protected  java.util.Map<java.lang.Object,KeyValueMessageGroup> groupIdToMessageGroup
          Required Region to managed the association of groups => KeyValueMessageGroup
protected  java.util.Map<java.lang.String,Message<?>> marked
          Required Region to manage the #marked data
protected  java.util.Map<java.lang.String,Message<?>> unmarked
          Required Region to manage the #unmarked data
 
Fields inherited from class org.springframework.integration.store.AbstractMessageGroupStore
logger
 
Constructor Summary
KeyValueMessageGroupStore(java.util.Map<java.lang.Object,KeyValueMessageGroup> groupIdToMessageGroup, java.util.Map<java.lang.String,Message<?>> marked, java.util.Map<java.lang.String,Message<?>> unmarked)
          Create a KeyValueMessageGroupStore with two backing regions to handle the state management.
 
Method Summary
 MessageGroup addMessageToGroup(java.lang.Object groupId, Message<?> message)
          Store a message with an association to a group id.
protected  KeyValueMessageGroup ensureMessageGroupHasReferencesToRegions(KeyValueMessageGroup keyValueMessageGroup)
           
 MessageGroup getMessageGroup(java.lang.Object groupId)
          Return all Messages currently in the MessageStore that were stored using MessageGroupStore.addMessageToGroup(Object, Message) with this group id.
protected  KeyValueMessageGroup getMessageGroupInternal(java.lang.Object groupId)
           
 java.util.Iterator<MessageGroup> iterator()
           
 MessageGroup markMessageFromGroup(java.lang.Object key, Message<?> messageToMark)
          Persist a mark on a single message from the group.
 MessageGroup markMessageGroup(MessageGroup group)
          Persist the mark on all the messages from the group.
 MessageGroup removeMessageFromGroup(java.lang.Object key, Message<?> messageToRemove)
          Persist a deletion on a single message from the group.
 void removeMessageGroup(java.lang.Object groupId)
          Remove the message group with this id.
 
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

groupIdToMessageGroup

protected java.util.Map<java.lang.Object,KeyValueMessageGroup> groupIdToMessageGroup
Required Region to managed the association of groups => KeyValueMessageGroup


unmarked

protected java.util.Map<java.lang.String,Message<?>> unmarked
Required Region to manage the #unmarked data


marked

protected java.util.Map<java.lang.String,Message<?>> marked
Required Region to manage the #marked data

Constructor Detail

KeyValueMessageGroupStore

public KeyValueMessageGroupStore(java.util.Map<java.lang.Object,KeyValueMessageGroup> groupIdToMessageGroup,
                                 java.util.Map<java.lang.String,Message<?>> marked,
                                 java.util.Map<java.lang.String,Message<?>> unmarked)
Create a KeyValueMessageGroupStore with two backing regions to handle the state management.

Parameters:
groupIdToMessageGroup - the region to associate
marked - the collection that will hold which messages are marked (delivered)
unmarked - the collection that holds which messages are unmarked (not yet delivered)
Method Detail

getMessageGroup

public MessageGroup getMessageGroup(java.lang.Object groupId)
Description copied from interface: MessageGroupStore
Return all Messages currently in the MessageStore that were stored using MessageGroupStore.addMessageToGroup(Object, Message) with this group id.

Returns:
a group of messages, empty if none exists for this key

addMessageToGroup

public MessageGroup addMessageToGroup(java.lang.Object groupId,
                                      Message<?> message)
Description copied from interface: MessageGroupStore
Store a message with an association to a group id. This can be used to group messages together.

Parameters:
groupId - the group id to store the message under
message - a message

markMessageGroup

public MessageGroup markMessageGroup(MessageGroup group)
Description copied from interface: MessageGroupStore
Persist the mark on all the messages from the group. The group is modified in the process as all its unmarked messages become marked.

Parameters:
group - a MessageGroup with no unmarked messages

removeMessageGroup

public void removeMessageGroup(java.lang.Object groupId)
Description copied from interface: MessageGroupStore
Remove the message group with this id.

Parameters:
groupId - the id of the group to remove

removeMessageFromGroup

public MessageGroup removeMessageFromGroup(java.lang.Object key,
                                           Message<?> messageToRemove)
Description copied from interface: MessageGroupStore
Persist a deletion on a single message from the group. The group is modified to reflect that 'messageToRemove' is no longer present in the group.

Parameters:
key - the groupId for the group containing the message
messageToRemove - the message to be removed

markMessageFromGroup

public MessageGroup markMessageFromGroup(java.lang.Object key,
                                         Message<?> messageToMark)
Description copied from interface: MessageGroupStore
Persist a mark on a single message from the group. The group is modified to reflect that 'messageToMark' is no longer unmarked but became marked instead.

Parameters:
key - the groupId for the group containing the message
messageToMark - the message to be marked

iterator

public java.util.Iterator<MessageGroup> iterator()
Specified by:
iterator in interface java.lang.Iterable<MessageGroup>
Specified by:
iterator in class AbstractMessageGroupStore

ensureMessageGroupHasReferencesToRegions

protected KeyValueMessageGroup ensureMessageGroupHasReferencesToRegions(KeyValueMessageGroup keyValueMessageGroup)

getMessageGroupInternal

protected KeyValueMessageGroup getMessageGroupInternal(java.lang.Object groupId)