Spring Integration

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 group id.

Since:
2.0
Author:
Dave Syer

Method Summary
 MessageGroup addMessageToGroup(Object groupId, Message<?> message)
          Store a message with an association to a group id.
 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(Object groupId)
          Return all Messages currently in the MessageStore that were stored using addMessageToGroup(Object, Message) with this group id.
 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(Object key, Message<?> messageToMark)
          Persist a mark on a single message from the group.
 void removeMessageGroup(Object groupId)
          Remove the message group with this id.
 

Method Detail

getMessageGroup

MessageGroup getMessageGroup(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(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(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(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)

Spring Integration

Copyright © 2010. All Rights Reserved.