Spring Integration

org.springframework.integration.store
Interface MessageGroupStore

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

public interface MessageGroupStore

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

Since:
2.0
Author:
Dave Syer, Oleg Zhurakousky

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 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
 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
 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

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

messageGroupSize

@ManagedAttribute
int messageGroupSize(java.lang.Object groupId)
Returns the size of this MessageGroup

Parameters:
groupId -

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

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

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


pollMessageFromGroup

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


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.


Spring Integration