Class AbstractMessageGroupStore
java.lang.Object
org.springframework.integration.store.AbstractBatchingMessageGroupStore
org.springframework.integration.store.AbstractMessageGroupStore
- All Implemented Interfaces:
- Iterable<MessageGroup>,- BasicMessageGroupStore,- MessageGroupStore
- Direct Known Subclasses:
- AbstractConfigurableMongoDbMessageStore,- AbstractKeyValueMessageStore,- JdbcMessageStore,- MongoDbMessageStore,- SimpleMessageStore
@ManagedResource
public abstract class AbstractMessageGroupStore
extends AbstractBatchingMessageGroupStore
implements MessageGroupStore, Iterable<MessageGroup>
- Since:
- 2.0
- Author:
- Dave Syer, Oleg Zhurakousky, Gary Russell, Artem Bilan, Christian Tzolov, Youbin Wu
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.store.MessageGroupStoreMessageGroupStore.MessageGroupCallback
- 
Field SummaryFields
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedprotectedAbstractMessageGroupStore(boolean lazyLoadMessageGroups) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddMessagesToGroup(Object groupId, Message<?>... messages) Store messages with an association to a group id.addMessageToGroup(Object groupId, Message<?> message) Store a message with an association to a group id.voidcompleteGroup(Object groupId) Completes this MessageGroup.protected MessageGroupcopy(MessageGroup group) Used by expireMessageGroups.protected abstract voiddoAddMessagesToGroup(Object groupId, Message<?>... messages) protected abstract voiddoCompleteGroup(Object groupId) protected abstract Message<?> doPollMessageFromGroup(Object groupId) protected booleandoRemoveMessageFromGroupById(Object groupId, UUID messageId) protected abstract voiddoRemoveMessageGroup(Object groupId) protected abstract voiddoRemoveMessagesFromGroup(Object key, Collection<Message<?>> messages) protected abstract voiddoSetGroupCondition(Object groupId, String condition) protected abstract voiddoSetLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber) protected <T, E extends RuntimeException>
 TexecuteLocked(Object groupId, CheckedCallable<T, E> runnable) protected <E extends RuntimeException>
 voidexecuteLocked(Object groupId, CheckedRunnable<E> runnable) intexpireMessageGroups(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.protected LockRegistryintOptional attribute giving the number of messages in the store over all groups.intOptional attribute giving the number of message groups.protected MessageGroupFactorybooleanMessage<?> pollMessageFromGroup(Object groupId) Poll Message from thisMessageGroup(in FIFO style if supported by the implementation) while also removing the polledMessage.voidRegister a callback for when a message group is expired throughMessageGroupStore.expireMessageGroups(long).booleanremoveMessageFromGroupById(Object groupId, UUID messageId) Deletion the message from the group.voidremoveMessageGroup(Object groupId) Remove the message group with this id.voidremoveMessagesFromGroup(Object key, Collection<Message<?>> messages) Persist the deletion of messages from the group.voidremoveMessagesFromGroup(Object key, Message<?>... messages) Persist the deletion of messages from the group.voidsetExpiryCallbacks(Collection<MessageGroupStore.MessageGroupCallback> expiryCallbacks) Convenient injection point for expiry callbacks in the message store.voidsetGroupCondition(Object groupId, String condition) Add a condition sentence into the group.voidsetLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber) Allows you to set the sequence number of the last released Message.voidsetLazyLoadMessageGroups(boolean lazyLoadMessageGroups) Specify if the result of theBasicMessageGroupStore.getMessageGroup(Object)should be wrapped to thePersistentMessageGroup- a lazy-load proxy for messages in group Defaults totrue.final voidsetLockRegistry(LockRegistry lockRegistry) Specify the type of theLockRegistryto ensure atomic operationsvoidsetTimeoutOnIdle(boolean timeoutOnIdle) Allows you to override the rule for the timeout calculation.Methods inherited from class org.springframework.integration.store.AbstractBatchingMessageGroupStoregetRemoveBatchSize, setMessageGroupFactory, setRemoveBatchSizeMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.integration.store.BasicMessageGroupStoregetMessageGroup, messageGroupSizeMethods inherited from interface java.lang.IterableforEach, iterator, spliteratorMethods inherited from interface org.springframework.integration.store.MessageGroupStoregetMessageFromGroup, getMessagesForGroup, getOneMessageFromGroup, iterator, streamMessagesForGroup
- 
Field Details- 
INTERRUPTED_WHILE_OBTAINING_LOCK- See Also:
 
- 
GROUP_ID_MUST_NOT_BE_NULL- See Also:
 
- 
logger
 
- 
- 
Constructor Details- 
AbstractMessageGroupStoreprotected AbstractMessageGroupStore()
- 
AbstractMessageGroupStoreprotected AbstractMessageGroupStore(boolean lazyLoadMessageGroups) 
 
- 
- 
Method Details- 
getMessageGroupFactory- Overrides:
- getMessageGroupFactoryin class- AbstractBatchingMessageGroupStore
 
- 
setExpiryCallbacksConvenient injection point for expiry callbacks in the message store. Each of the callbacks provided will simply be registered with the store usingregisterMessageGroupExpiryCallback(MessageGroupCallback).- Parameters:
- expiryCallbacks- the expiry callbacks to add
 
- 
isTimeoutOnIdlepublic boolean isTimeoutOnIdle()
- 
setTimeoutOnIdlepublic void setTimeoutOnIdle(boolean timeoutOnIdle) Allows you to override the rule for the timeout calculation. Typical timeout is based from the time theMessageGroupwas created. If you want the timeout to be based on the time theMessageGroupwas idling (e.g., inactive from the last update) invoke this method with 'true'. Default is 'false'.- Parameters:
- timeoutOnIdle- The boolean.
 
- 
setLazyLoadMessageGroupspublic void setLazyLoadMessageGroups(boolean lazyLoadMessageGroups) Specify if the result of theBasicMessageGroupStore.getMessageGroup(Object)should be wrapped to thePersistentMessageGroup- a lazy-load proxy for messages in group Defaults totrue.The target logic is based on the SimpleMessageGroupFactory.GroupType.PERSISTENT.- Parameters:
- lazyLoadMessageGroups- the- booleanflag to use.
- Since:
- 4.3
 
- 
setLockRegistrySpecify the type of theLockRegistryto ensure atomic operations- Parameters:
- lockRegistry- lockRegistryType
- Since:
- 6.5
 
- 
getLockRegistry
- 
registerMessageGroupExpiryCallbackDescription copied from interface:MessageGroupStoreRegister a callback for when a message group is expired throughMessageGroupStore.expireMessageGroups(long).- Specified by:
- registerMessageGroupExpiryCallbackin interface- MessageGroupStore
- Parameters:
- callback- A callback to execute when a message group is cleaned up.
 
- 
expireMessageGroupsDescription copied from interface:MessageGroupStoreExtract 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.- Specified by:
- expireMessageGroupsin interface- MessageGroupStore
- Parameters:
- timeout- the timeout threshold to use
- Returns:
- the number of message groups expired
- See Also:
 
- 
copyUsed by expireMessageGroups. We need to return a snapshot of the group at the time the reaper runs, so we can properly detect if the group changed between now and the attempt to expire the group. Not necessary for persistent stores, so the default behavior is to just return the group.- Parameters:
- group- The group.
- Returns:
- The group, or a copy.
- Since:
- 4.0.1
 
- 
getMessageCountForAllMessageGroupsDescription copied from interface:MessageGroupStoreOptional attribute giving the number of messages in the store over all groups. Implementations may decline to respond by throwing an exception.- Specified by:
- getMessageCountForAllMessageGroupsin interface- MessageGroupStore
- Returns:
- the number of messages
 
- 
getMessageGroupCountDescription copied from interface:MessageGroupStoreOptional attribute giving the number of message groups. Implementations may decline to respond by throwing an exception.- Specified by:
- getMessageGroupCountin interface- MessageGroupStore
- Returns:
- the number message groups
 
- 
getGroupMetadataDescription copied from interface:MessageGroupStoreObtain the group metadata without fetching any messages; must supply all other group properties; may include the id of the first message.- Specified by:
- getGroupMetadatain interface- MessageGroupStore
- Parameters:
- groupId- The group id.
- Returns:
- The metadata.
 
- 
removeMessagesFromGroupDescription copied from interface:MessageGroupStorePersist the deletion of messages from the group.- Specified by:
- removeMessagesFromGroupin interface- MessageGroupStore
- Parameters:
- key- The groupId for the group containing the message(s).
- messages- The messages to be removed.
 
- 
removeMessagesFromGroupDescription copied from interface:MessageGroupStorePersist the deletion of messages from the group.- Specified by:
- removeMessagesFromGroupin interface- MessageGroupStore
- Parameters:
- key- The groupId for the group containing the message(s).
- messages- The messages to be removed.
 
- 
doRemoveMessagesFromGroup
- 
addMessagesToGroupDescription copied from interface:MessageGroupStoreStore messages with an association to a group id. This can be used to group messages together.- Specified by:
- addMessagesToGroupin interface- MessageGroupStore
- Parameters:
- groupId- The group id to store messages under.
- messages- The messages to add.
 
- 
doAddMessagesToGroup
- 
addMessageToGroupDescription copied from interface:BasicMessageGroupStoreStore a message with an association to a group id. This can be used to group messages together.- Specified by:
- addMessageToGroupin interface- BasicMessageGroupStore
- Parameters:
- groupId- The group id to store the message under.
- message- A message.
- Returns:
- The message group.
 
- 
removeMessageGroupDescription copied from interface:BasicMessageGroupStoreRemove the message group with this id.- Specified by:
- removeMessageGroupin interface- BasicMessageGroupStore
- Parameters:
- groupId- The id of the group to remove.
 
- 
doRemoveMessageGroup
- 
removeMessageFromGroupByIdDescription copied from interface:MessageGroupStoreDeletion the message from the group.- Specified by:
- removeMessageFromGroupByIdin interface- MessageGroupStore
- Parameters:
- groupId- The groupId for the group containing the message.
- messageId- The message id to be removed.
- Returns:
- true if message has been removed.
 
- 
doRemoveMessageFromGroupById
- 
setLastReleasedSequenceNumberForGroupDescription copied from interface:MessageGroupStoreAllows you to set the sequence number of the last released Message. Used for Resequencing use cases- Specified by:
- setLastReleasedSequenceNumberForGroupin interface- MessageGroupStore
- Parameters:
- groupId- The group identifier.
- sequenceNumber- The sequence number.
 
- 
doSetLastReleasedSequenceNumberForGroup
- 
completeGroupDescription copied from interface:MessageGroupStoreCompletes 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.- Specified by:
- completeGroupin interface- MessageGroupStore
- Parameters:
- groupId- The group identifier.
 
- 
doCompleteGroup
- 
setGroupConditionDescription copied from interface:MessageGroupStoreAdd 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.- Specified by:
- setGroupConditionin interface- MessageGroupStore
- Parameters:
- groupId- The group identifier.
- condition- The condition to store into the group.
 
- 
doSetGroupCondition
- 
pollMessageFromGroupDescription copied from interface:BasicMessageGroupStorePoll Message from thisMessageGroup(in FIFO style if supported by the implementation) while also removing the polledMessage.- Specified by:
- pollMessageFromGroupin interface- BasicMessageGroupStore
- Parameters:
- groupId- The group identifier.
- Returns:
- The message.
 
- 
doPollMessageFromGroup
- 
executeLockedprotected <T, E extends RuntimeException> T executeLocked(Object groupId, CheckedCallable<T, E> runnable) 
- 
executeLockedprotected <E extends RuntimeException> void executeLocked(Object groupId, CheckedRunnable<E> runnable) 
 
-