org.springframework.integration.store
Interface MessageGroupStore

All Known Implementing Classes:
AbstractKeyValueMessageStore, AbstractMessageGroupStore, GemfireMessageStore, JdbcMessageStore, MongoDbMessageStore, RedisMessageStore, SimpleMessageStore

public interface MessageGroupStore

Interface for storage operations on groups of messages linked by a group id.

Since:
2.0

Method Summary
 MessageGroup addMessageToGroup(java.lang.Object groupId, Message<?> message)
          Store a message with an association to a group id.
 void completeGroup(java.lang.Object groupId)
          Completes this MessageGroup.
 int expireMessageGroups(long timeout)
          Extract all expired groups (whose timestamp is older than the current time less the threshold provided) and call each of the registered callbacks on them in turn.
 int getMarkedMessageCountForAllMessageGroups()
          Optional attribute giving the number of marked messages in the store for all groups.
 int getMessageCountForAllMessageGroups()
          Optional attribute giving the number of messages in the store over all groups.
 MessageGroup getMessageGroup(java.lang.Object groupId)
          Return all Messages currently in the MessageStore that were stored using addMessageToGroup(Object, Message) with this group id.
 int getMessageGroupCount()
          Optional attribute giving the number of message groups.
 java.util.Iterator<MessageGroup> iterator()
          Returns the iterator of currently accumulated MessageGroups
 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.
 void registerMessageGroupExpiryCallback(MessageGroupCallback callback)
          Register a callback for when a message group is expired through expireMessageGroups(long).
 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.
 void setLastReleasedSequenceNumberForGroup(java.lang.Object groupId, int sequenceNumber)
          Allows you to set the sequence number of the last released Message.
 

Method Detail

getMessageCountForAllMessageGroups

@ManagedAttribute
int getMessageCountForAllMessageGroups()
Optional attribute giving the number of messages in the store over all groups. Implementations may decline to respond by throwing an exception.

Returns:
the number of messages
Throws:
java.lang.UnsupportedOperationException - if not implemented

getMarkedMessageCountForAllMessageGroups

@ManagedAttribute
int getMarkedMessageCountForAllMessageGroups()
Optional attribute giving the number of marked messages in the store for all groups. Implementations may decline to respond by throwing an exception.

Returns:
the number of marked messages in each group
Throws:
java.lang.UnsupportedOperationException - if not implemented

getMessageGroupCount

@ManagedAttribute
int getMessageGroupCount()
Optional attribute giving the number of message groups. Implementations may decline to respond by throwing an exception.

Returns:
the number message groups
Throws:
java.lang.UnsupportedOperationException - if not implemented

getMessageGroup

MessageGroup getMessageGroup(java.lang.Object groupId)
Return all Messages currently in the MessageStore that were stored using addMessageToGroup(Object, Message) with this group id.

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

addMessageToGroup

MessageGroup addMessageToGroup(java.lang.Object groupId,
                               Message<?> message)
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

MessageGroup markMessageGroup(MessageGroup group)
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

removeMessageFromGroup

MessageGroup removeMessageFromGroup(java.lang.Object key,
                                    Message<?> messageToRemove)
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

MessageGroup markMessageFromGroup(java.lang.Object key,
                                  Message<?> messageToMark)
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

removeMessageGroup

void removeMessageGroup(java.lang.Object groupId)
Remove the message group with this id.

Parameters:
groupId - the id of the group to remove

registerMessageGroupExpiryCallback

void registerMessageGroupExpiryCallback(MessageGroupCallback callback)
Register a callback for when a message group is expired through expireMessageGroups(long).

Parameters:
callback - a callback to execute when a message group is cleaned up

expireMessageGroups

int expireMessageGroups(long timeout)
Extract all expired groups (whose timestamp is older than the current time less the threshold provided) and call each of the registered callbacks on them in turn. For example: call with a timeout of 100 to expire all groups that were created more than 100 milliseconds ago, and are not yet complete. Use a timeout of 0 (or negative to be on the safe side) to expire all message groups.

Parameters:
timeout - the timeout threshold to use
Returns:
the number of message groups expired
See Also:
registerMessageGroupExpiryCallback(MessageGroupCallback)

setLastReleasedSequenceNumberForGroup

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

Parameters:
sequenceNumber -

iterator

java.util.Iterator<MessageGroup> iterator()
Returns the iterator of currently accumulated MessageGroups


completeGroup

void completeGroup(java.lang.Object groupId)
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.