org.springframework.integration.store
Interface MessageGroupStore

All Known Implementing Classes:
AbstractMessageGroupStore, JdbcMessageStore, SimpleMessageStore

public interface MessageGroupStore

Interface for storage operations on groups of messages linked by a correlation key.

Since:
2.0
Author:
Dave Syer

Method Summary
 void addMessageToGroup(java.lang.Object correlationKey, Message<?> message)
          Store a message with an association to a correlation key.
 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.
 MessageGroup getMessageGroup(java.lang.Object correlationKey)
          Return all Messages currently in the MessageStore that were stored using #addMessageToGroup(Object, Collection) with this correlation id.
 void 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).
 void removeMessageGroup(java.lang.Object correlationKey)
          Remove the message group with this correlation key.
 

Method Detail

getMessageGroup

MessageGroup getMessageGroup(java.lang.Object correlationKey)
Return all Messages currently in the MessageStore that were stored using #addMessageToGroup(Object, Collection) with this correlation id.

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

addMessageToGroup

void addMessageToGroup(java.lang.Object correlationKey,
                       Message<?> message)
Store a message with an association to a correlation key. This can be used to group messages together instead of storing them just under their id.

Parameters:
correlationKey - the correlation id to store the message under
message - a message

markMessageGroup

void 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

removeMessageGroup

void removeMessageGroup(java.lang.Object correlationKey)
Remove the message group with this correlation key.

Parameters:
correlationKey - the correlation id 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)