Interface MessageGroupStore
- All Superinterfaces:
BasicMessageGroupStore
- All Known Implementing Classes:
AbstractConfigurableMongoDbMessageStore
,AbstractKeyValueMessageStore
,AbstractMessageGroupStore
,ConfigurableMongoDbMessageStore
,HazelcastMessageStore
,JdbcMessageStore
,MongoDbChannelMessageStore
,MongoDbMessageStore
,RedisMessageStore
,SimpleMessageStore
Defines additional storage operations on groups of messages linked by a group id.
- Since:
- 2.0
- Author:
- Dave Syer, Oleg Zhurakousky, Gary Russell, Artem Bilan
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Invoked when a MessageGroupStore expires a group. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMessagesToGroup
(Object groupId, Message<?>... messages) Store messages with an association to a group id.void
completeGroup
(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.getGroupMetadata
(Object groupId) Obtain the group metadata without fetching any messages; must supply all other group properties; may include the id of the first message.int
Optional attribute giving the number of messages in the store over all groups.default Message<?>
getMessageFromGroup
(Object groupId, UUID messageId) Retrieve aMessage
from a group by id.int
Optional attribute giving the number of message groups.Collection<Message<?>>
getMessagesForGroup
(Object groupId) Retrieve messages for the provided group id.Message<?>
getOneMessageFromGroup
(Object groupId) Return the oneMessage
fromMessageGroup
.iterator()
void
Register a callback for when a message group is expired throughexpireMessageGroups(long)
.default boolean
removeMessageFromGroupById
(Object groupId, UUID messageId) Deletion the message from the group.void
removeMessagesFromGroup
(Object key, Collection<Message<?>> messages) Persist the deletion of messages from the group.void
removeMessagesFromGroup
(Object key, Message<?>... messages) Persist the deletion of messages from the group.void
setGroupCondition
(Object groupId, String condition) Add a condition sentence into the group.void
setLastReleasedSequenceNumberForGroup
(Object groupId, int sequenceNumber) Allows you to set the sequence number of the last released Message.streamMessagesForGroup
(Object groupId) Return a stream for messages stored in the provided group.Methods inherited from interface org.springframework.integration.store.BasicMessageGroupStore
addMessageToGroup, getMessageGroup, messageGroupSize, pollMessageFromGroup, removeMessageGroup
-
Method Details
-
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:
UnsupportedOperationException
- if not implemented
-
getMessageGroupCount
Optional attribute giving the number of message groups. Implementations may decline to respond by throwing an exception.- Returns:
- the number message groups
- Throws:
UnsupportedOperationException
- if not implemented
-
removeMessagesFromGroup
Persist the deletion of messages from the group.- Parameters:
key
- The groupId for the group containing the message(s).messages
- The messages to be removed.- Since:
- 4.2
-
removeMessagesFromGroup
Persist the deletion of messages from the group.- Parameters:
key
- The groupId for the group containing the message(s).messages
- The messages to be removed.- Since:
- 4.2
-
getMessageFromGroup
Retrieve aMessage
from a group by id. Returnnull
if message does not belong to the requested group.- Parameters:
groupId
- The groupId for the group containing the message.messageId
- The message id.- Returns:
- message by id if it belongs to requested group.
- Since:
- 6.1.5
-
removeMessageFromGroupById
Deletion the message from the group.- Parameters:
groupId
- The groupId for the group containing the message.messageId
- The message id to be removed.- Returns:
- true if message has been removed.
- Since:
- 6.1.5
-
registerMessageGroupExpiryCallback
Register a callback for when a message group is expired throughexpireMessageGroups(long)
.- Parameters:
callback
- A callback to execute when a message group is cleaned up.
-
expireMessageGroups
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:
-
setLastReleasedSequenceNumberForGroup
Allows you to set the sequence number of the last released Message. Used for Resequencing use cases- Parameters:
groupId
- The group identifier.sequenceNumber
- The sequence number.
-
setGroupCondition
Add a condition sentence into the group. Can be used later on for making some decisions for group, e.g. release strategy for correlation handler can consult this condition instead of iterating all the messages in group.- Parameters:
groupId
- The group identifier.condition
- The condition to store into the group.- Since:
- 5.5
-
iterator
Iterator<MessageGroup> iterator()- Returns:
- The iterator of currently accumulated
MessageGroup
s.
-
completeGroup
Completes this MessageGroup. Completion of the MessageGroup generally means that this group should not be allowing anymore mutating operation to be performed on it. For example any attempt to add/remove new Message form the group should not be allowed.- Parameters:
groupId
- The group identifier.
-
getGroupMetadata
Obtain the group metadata without fetching any messages; must supply all other group properties; may include the id of the first message.- Parameters:
groupId
- The group id.- Returns:
- The metadata.
- Since:
- 4.0
-
getOneMessageFromGroup
Return the oneMessage
fromMessageGroup
.- Parameters:
groupId
- The group identifier.- Returns:
- the
Message
. - Since:
- 4.0
-
addMessagesToGroup
Store messages with an association to a group id. This can be used to group messages together.- Parameters:
groupId
- The group id to store messages under.messages
- The messages to add.- Since:
- 4.3
-
getMessagesForGroup
Retrieve messages for the provided group id.- Parameters:
groupId
- The group id to retrieve messages for.- Returns:
- the messages for group.
- Since:
- 4.3
-
streamMessagesForGroup
Return a stream for messages stored in the provided group. The persistent implementations return a Stream which has to be closed once fully processed (e.g. through a try-with-resources clause). By default, it streams a result ofgetMessagesForGroup(Object)
.- Parameters:
groupId
- the group id to retrieve messages.- Returns:
- the
Stream
for messages in this group. - Since:
- 5.5
-