Class SimpleMessageStore
java.lang.Object
org.springframework.integration.store.AbstractBatchingMessageGroupStore
org.springframework.integration.store.AbstractMessageGroupStore
org.springframework.integration.store.SimpleMessageStore
- All Implemented Interfaces:
- Iterable<MessageGroup>,- BasicMessageGroupStore,- ChannelMessageStore,- MessageGroupStore,- MessageStore
public class SimpleMessageStore
extends AbstractMessageGroupStore
implements MessageStore, ChannelMessageStore
Map-based in-memory implementation of 
MessageStore and MessageGroupStore.
 Enforces a maximum capacity for the store.- Since:
- 2.0
- Author:
- Iwein Fuld, Mark Fisher, Dave Syer, Oleg Zhurakousky, Gary Russell, Ryan Barker, Artem Bilan, Youbin Wu
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.store.MessageGroupStoreMessageGroupStore.MessageGroupCallback
- 
Field SummaryFields inherited from class org.springframework.integration.store.AbstractMessageGroupStoreGROUP_ID_MUST_NOT_BE_NULL, INTERRUPTED_WHILE_OBTAINING_LOCK, logger
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a SimpleMessageStore with unlimited capacity.SimpleMessageStore(int capacity) Creates a SimpleMessageStore with the same capacity for individual and grouped messages.SimpleMessageStore(int individualCapacity, int groupCapacity) Creates a SimpleMessageStore with a maximum size limited by the given capacity, or unlimited size if the given capacity is less than 1.SimpleMessageStore(int individualCapacity, int groupCapacity, long upperBoundTimeout) Create a SimpleMessageStore with a maximum size limited by the given capacity and the timeout in millisecond to wait for the empty slot in the store.SimpleMessageStore(int individualCapacity, int groupCapacity, long upperBoundTimeout, LockRegistry lockRegistry) Creates a SimpleMessageStore with a maximum size limited by the given capacity, the timeout in millisecond to wait for the empty slot in the store and LockRegistry for the message group operations concurrency.SimpleMessageStore(int individualCapacity, int groupCapacity, LockRegistry lockRegistry) Creates a SimpleMessageStore with a maximum size limited by the given capacity and LockRegistry for the message group operations concurrency.
- 
Method SummaryModifier and TypeMethodDescription<T> Message<T> addMessage(Message<T> message) Put the provided Message into the MessageStore.voidaddMessagesToGroup(Object groupId, Message<?>... messages) Store messages with an association to a group id.voidclearMessageGroup(Object groupId) protected MessageGroupcopy(MessageGroup group) Used by expireMessageGroups.protected voiddoAddMessagesToGroup(Object groupId, Message<?>... messages) protected voiddoCompleteGroup(Object groupId) protected Message<?> doPollMessageFromGroup(Object groupId) protected booleandoRemoveMessageFromGroupById(Object groupId, UUID messageId) protected voiddoRemoveMessageGroup(Object groupId) protected voiddoRemoveMessagesFromGroup(Object groupId, Collection<Message<?>> messages) protected voiddoSetGroupCondition(Object groupId, String condition) protected voiddoSetLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber) 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.Message<?> getMessage(UUID key) longOptional attribute giving the number of messages in the store.Message<?> getMessageFromGroup(Object groupId, UUID messageId) Retrieve aMessagefrom a group by id.getMessageGroup(Object groupId) Return all Messages currently in the MessageStore that were stored usingBasicMessageGroupStore.addMessageToGroup(Object, Message)with this group id.Collection<Message<?>> getMessagesForGroup(Object groupId) Retrieve messages for the provided group id.Message<?> getOneMessageFromGroup(Object groupId) Return the oneMessagefromMessageGroup.iterator()intmessageGroupSize(Object groupId) Return the size of this MessageGroup.Message<?> removeMessage(UUID key) Remove the Message with the given id from the MessageStore, if present, and return it.voidsetCopyOnGet(boolean copyOnGet) Set as false to disable copying the group ingetMessageGroup(Object).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.Methods inherited from class org.springframework.integration.store.AbstractMessageGroupStoreaddMessageToGroup, completeGroup, executeLocked, executeLocked, expireMessageGroups, getLockRegistry, getMessageCountForAllMessageGroups, getMessageGroupCount, getMessageGroupFactory, isTimeoutOnIdle, pollMessageFromGroup, registerMessageGroupExpiryCallback, removeMessageFromGroupById, removeMessageGroup, removeMessagesFromGroup, removeMessagesFromGroup, setExpiryCallbacks, setGroupCondition, setLastReleasedSequenceNumberForGroup, setLockRegistry, setTimeoutOnIdleMethods 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.BasicMessageGroupStoreaddMessageToGroup, pollMessageFromGroup, removeMessageGroupMethods inherited from interface java.lang.IterableforEach, spliteratorMethods inherited from interface org.springframework.integration.store.MessageGroupStorestreamMessagesForGroup
- 
Constructor Details- 
SimpleMessageStorepublic SimpleMessageStore(int individualCapacity, int groupCapacity) Creates a SimpleMessageStore with a maximum size limited by the given capacity, or unlimited size if the given capacity is less than 1. The capacities are applied independently to messages stored viaaddMessage(Message)and to those stored viaAbstractMessageGroupStore.addMessageToGroup(Object, Message). In both cases the capacity applies to the number of messages that can be stored, and once that limit is reached attempting to store another will result in an exception.- Parameters:
- individualCapacity- The message capacity.
- groupCapacity- The capacity of each group.
 
- 
SimpleMessageStorepublic SimpleMessageStore(int individualCapacity, int groupCapacity, long upperBoundTimeout) Create a SimpleMessageStore with a maximum size limited by the given capacity and the timeout in millisecond to wait for the empty slot in the store.- Parameters:
- individualCapacity- The message capacity.
- groupCapacity- The capacity of each group.
- upperBoundTimeout- The time to wait if the store is at max capacity.
- Since:
- 4.3
- See Also:
 
- 
SimpleMessageStoreCreates a SimpleMessageStore with a maximum size limited by the given capacity and LockRegistry for the message group operations concurrency.- Parameters:
- individualCapacity- The message capacity.
- groupCapacity- The capacity of each group.
- lockRegistry- The lock registry.
- See Also:
 
- 
SimpleMessageStorepublic SimpleMessageStore(int individualCapacity, int groupCapacity, long upperBoundTimeout, LockRegistry lockRegistry) Creates a SimpleMessageStore with a maximum size limited by the given capacity, the timeout in millisecond to wait for the empty slot in the store and LockRegistry for the message group operations concurrency.- Parameters:
- individualCapacity- The message capacity.
- groupCapacity- The capacity of each group.
- upperBoundTimeout- The time to wait if the store is at max capacity
- lockRegistry- The lock registry.
- Since:
- 4.3
 
- 
SimpleMessageStorepublic SimpleMessageStore(int capacity) Creates a SimpleMessageStore with the same capacity for individual and grouped messages.- Parameters:
- capacity- The capacity.
 
- 
SimpleMessageStorepublic SimpleMessageStore()Create a SimpleMessageStore with unlimited capacity.
 
- 
- 
Method Details- 
setCopyOnGetpublic void setCopyOnGet(boolean copyOnGet) Set as false to disable copying the group ingetMessageGroup(Object). Starting with 4.1, this is false by default.- Parameters:
- copyOnGet- True to copy, false to not.
- Since:
- 4.0.1
 
- 
setLazyLoadMessageGroupspublic void setLazyLoadMessageGroups(boolean lazyLoadMessageGroups) Description copied from class:AbstractMessageGroupStoreSpecify 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.- Overrides:
- setLazyLoadMessageGroupsin class- AbstractMessageGroupStore
- Parameters:
- lazyLoadMessageGroups- the- booleanflag to use.
 
- 
getMessageCountDescription copied from interface:MessageStoreOptional attribute giving the number of messages in the store. Implementations may decline to respond by throwing an exception.- Specified by:
- getMessageCountin interface- MessageStore
- Returns:
- The number of messages.
 
- 
addMessageDescription copied from interface:MessageStorePut the provided Message into the MessageStore. The store may need to mutate the message internally, and if it does then the return value can be different than the input. The id of the return value will be used as an index so that theMessageStore.getMessage(UUID)andMessageStore.removeMessage(UUID)behave properly. Since messages are immutable, putting the same message more than once is a no-op.- Specified by:
- addMessagein interface- MessageStore
- Type Parameters:
- T- The payload type.
- Parameters:
- message- The message.
- Returns:
- The message that was stored.
 
- 
getMessage- Specified by:
- getMessagein interface- MessageStore
- Parameters:
- key- The message identifier.
- Returns:
- The Message with the given id, or null if no Message with that id exists in the MessageStore.
 
- 
getMessageMetadataDescription copied from interface:MessageStore- Specified by:
- getMessageMetadatain interface- MessageStore
- Parameters:
- id- The message identifier.
- Returns:
- The MessageMetadata with the given id, or null if no Message with that id exists in the MessageStore or the message has no metadata (legacy message from an earlier version).
 
- 
removeMessageDescription copied from interface:MessageStoreRemove the Message with the given id from the MessageStore, if present, and return it. If no Message with that id is present in the store, this will returnnull. If this method is implemented on aMessageGroupStore, the message is removed from the store only if no groups holding this message.- Specified by:
- removeMessagein interface- MessageStore
- Parameters:
- key- the message identifier.
- Returns:
- the message (if any).
 
- 
getMessageGroupDescription copied from interface:BasicMessageGroupStoreReturn all Messages currently in the MessageStore that were stored usingBasicMessageGroupStore.addMessageToGroup(Object, Message)with this group id.- Specified by:
- getMessageGroupin interface- BasicMessageGroupStore
- Parameters:
- groupId- The group identifier.
- Returns:
- A group of messages, empty if none exists for this key.
 
- 
copyDescription copied from class:AbstractMessageGroupStoreUsed 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.- Overrides:
- copyin class- AbstractMessageGroupStore
- Parameters:
- group- The group.
- Returns:
- The group, or a copy.
 
- 
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
- Overrides:
- addMessagesToGroupin class- AbstractMessageGroupStore
- Parameters:
- groupId- The group id to store messages under.
- messages- The messages to add.
 
- 
doAddMessagesToGroup- Specified by:
- doAddMessagesToGroupin class- AbstractMessageGroupStore
 
- 
doRemoveMessageGroup- Specified by:
- doRemoveMessageGroupin class- AbstractMessageGroupStore
 
- 
doRemoveMessagesFromGroup- Specified by:
- doRemoveMessagesFromGroupin class- AbstractMessageGroupStore
 
- 
getMessageFromGroupDescription copied from interface:MessageGroupStoreRetrieve aMessagefrom a group by id. Returnnullif message does not belong to the requested group.- Specified by:
- getMessageFromGroupin interface- MessageGroupStore
- Parameters:
- groupId- The groupId for the group containing the message.
- messageId- The message id.
- Returns:
- message by id if it belongs to requested group.
 
- 
doRemoveMessageFromGroupById- Overrides:
- doRemoveMessageFromGroupByIdin class- AbstractMessageGroupStore
 
- 
iterator- Specified by:
- iteratorin interface- Iterable<MessageGroup>
- Specified by:
- iteratorin interface- MessageGroupStore
- Returns:
- The iterator of currently accumulated MessageGroups.
 
- 
doSetGroupCondition- Specified by:
- doSetGroupConditionin class- AbstractMessageGroupStore
 
- 
doSetLastReleasedSequenceNumberForGroup- Specified by:
- doSetLastReleasedSequenceNumberForGroupin class- AbstractMessageGroupStore
 
- 
doCompleteGroup- Specified by:
- doCompleteGroupin class- AbstractMessageGroupStore
 
- 
doPollMessageFromGroup- Specified by:
- doPollMessageFromGroupin class- AbstractMessageGroupStore
 
- 
messageGroupSizeDescription copied from interface:BasicMessageGroupStoreReturn the size of this MessageGroup.- Specified by:
- messageGroupSizein interface- BasicMessageGroupStore
- Parameters:
- groupId- The group identifier.
- Returns:
- The size.
 
- 
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
- Overrides:
- getGroupMetadatain class- AbstractMessageGroupStore
- Parameters:
- groupId- The group id.
- Returns:
- The metadata.
 
- 
getOneMessageFromGroupDescription copied from interface:MessageGroupStoreReturn the oneMessagefromMessageGroup.- Specified by:
- getOneMessageFromGroupin interface- MessageGroupStore
- Parameters:
- groupId- The group identifier.
- Returns:
- the Message.
 
- 
getMessagesForGroupDescription copied from interface:MessageGroupStoreRetrieve messages for the provided group id.- Specified by:
- getMessagesForGroupin interface- MessageGroupStore
- Parameters:
- groupId- The group id to retrieve messages for.
- Returns:
- the messages for group.
 
- 
clearMessageGroup
 
-