Class AbstractKeyValueMessageStore
java.lang.Object
org.springframework.integration.store.AbstractBatchingMessageGroupStore
org.springframework.integration.store.AbstractMessageGroupStore
org.springframework.integration.store.AbstractKeyValueMessageStore
- All Implemented Interfaces:
Iterable<MessageGroup>,BasicMessageGroupStore,MessageGroupStore,MessageStore
- Direct Known Subclasses:
GemfireMessageStore,RedisMessageStore
public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupStore implements MessageStore
Base class for implementations of Key/Value style
MessageGroupStore and MessageStore- Since:
- 2.1
- Author:
- Oleg Zhurakousky, Gary Russell, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.store.MessageGroupStore
MessageGroupStore.MessageGroupCallback -
Field Summary
Fields Modifier and Type Field Description protected static StringMESSAGE_GROUP_KEY_PREFIXprotected static StringMESSAGE_KEY_PREFIX -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractKeyValueMessageStore()protectedAbstractKeyValueMessageStore(String prefix)Construct an instance based on the provided prefix for keys to distinguish between different store instances in the same target key-value data base. -
Method Summary
Modifier and Type Method Description <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.voidcompleteGroup(Object groupId)Completes this MessageGroup.protected voiddoAddMessage(Message<?> message)protected abstract Collection<?>doListKeys(String keyPattern)protected abstract ObjectdoRemove(Object id)protected abstract voiddoRemoveAll(Collection<Object> ids)protected abstract ObjectdoRetrieve(Object id)protected abstract voiddoStore(Object id, Object objectToStore)protected abstract voiddoStoreIfAbsent(Object id, Object objectToStore)MessageGroupMetadatagetGroupMetadata(Object groupId)Obtain the group metadata without fetching any messages; must supply all other group properties; may include the id of the first message.StringgetGroupPrefix()Return the configured prefix for message group keys to distinguish between different store instances in the same target key-value data base.Message<?>getMessage(UUID messageId)longgetMessageCount()Optional attribute giving the number of messages in the store.MessageGroupgetMessageGroup(Object groupId)Will create a new instance of SimpleMessageGroup if necessary.MessageMetadatagetMessageMetadata(UUID messageId)protected StringgetMessagePrefix()Return the configured prefix for message keys to distinguish between different store instances in the same target key-value data base.Collection<Message<?>>getMessagesForGroup(Object groupId)Retrieve messages for the provided group id.Message<?>getOneMessageFromGroup(Object groupId)Return the oneMessagefromMessageGroup.Iterator<MessageGroup>iterator()intmessageGroupSize(Object groupId)Returns the size of this MessageGroup.Message<?>pollMessageFromGroup(Object groupId)Polls Message from thisMessageGroup(in FIFO style if supported by the implementation) while also removing the polledMessageMessage<?>removeMessage(UUID id)Remove the Message with the given id from the MessageStore, if present, and return it.voidremoveMessageGroup(Object groupId)Remove the MessageGroup with the provided group ID.voidremoveMessagesFromGroup(Object groupId, Collection<Message<?>> messages)Persist the deletion of messages from the group.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.Stream<Message<?>>streamMessagesForGroup(Object groupId)Return a stream for messages stored in the provided group.Methods inherited from class org.springframework.integration.store.AbstractMessageGroupStore
addMessageToGroup, copy, expireMessageGroups, getMessageCountForAllMessageGroups, getMessageGroupCount, getMessageGroupFactory, isTimeoutOnIdle, registerMessageGroupExpiryCallback, removeMessagesFromGroup, setExpiryCallbacks, setLazyLoadMessageGroups, setTimeoutOnIdleMethods inherited from class org.springframework.integration.store.AbstractBatchingMessageGroupStore
getRemoveBatchSize, setMessageGroupFactory, setRemoveBatchSize
-
Field Details
-
MESSAGE_KEY_PREFIX
- See Also:
- Constant Field Values
-
MESSAGE_GROUP_KEY_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Details
-
AbstractKeyValueMessageStore
protected AbstractKeyValueMessageStore() -
AbstractKeyValueMessageStore
Construct an instance based on the provided prefix for keys to distinguish between different store instances in the same target key-value data base. Defaults to an empty string - no prefix. The actual prefix for messages isprefix + MESSAGE_; for message groups -prefix + MESSAGE_GROUP_- Parameters:
prefix- the prefix to use- Since:
- 4.3.12
-
-
Method Details
-
getMessagePrefix
Return the configured prefix for message keys to distinguish between different store instances in the same target key-value data base. Defaults to the "MESSAGE_" - without a custom prefix.- Returns:
- the prefix for keys
- Since:
- 4.3.12
-
getGroupPrefix
Return the configured prefix for message group keys to distinguish between different store instances in the same target key-value data base. Defaults to the "MESSAGE_GROUP_" - without custom prefix.- Returns:
- the prefix for keys
- Since:
- 4.3.12
-
getMessage
- Specified by:
getMessagein interfaceMessageStore- Parameters:
messageId- The message identifier.- Returns:
- The Message with the given id, or null if no Message with that id exists in the MessageStore.
-
getMessageMetadata
Description copied from interface:MessageStore- Specified by:
getMessageMetadatain interfaceMessageStore- Parameters:
messageId- 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).
-
addMessage
Description 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 interfaceMessageStore- Type Parameters:
T- The payload type.- Parameters:
message- The message.- Returns:
- The message that was stored.
-
doAddMessage
-
removeMessage
Description 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 return null.- Specified by:
removeMessagein interfaceMessageStore- Parameters:
id- THe message identifier.- Returns:
- The message.
-
getMessageCount
Description 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 interfaceMessageStore- Returns:
- The number of messages.
-
getMessageGroup
Will create a new instance of SimpleMessageGroup if necessary.- Specified by:
getMessageGroupin interfaceBasicMessageGroupStore- Parameters:
groupId- The group identifier.- Returns:
- A group of messages, empty if none exists for this key.
-
getGroupMetadata
Description 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 interfaceMessageGroupStore- Overrides:
getGroupMetadatain classAbstractMessageGroupStore- Parameters:
groupId- The group id.- Returns:
- The metadata.
-
addMessagesToGroup
Description copied from interface:MessageGroupStoreStore messages with an association to a group id. This can be used to group messages together.- Specified by:
addMessagesToGroupin interfaceMessageGroupStore- Parameters:
groupId- The group id to store messages under.messages- The messages to add.
-
removeMessagesFromGroup
Description copied from interface:MessageGroupStorePersist the deletion of messages from the group.- Specified by:
removeMessagesFromGroupin interfaceMessageGroupStore- Parameters:
groupId- The groupId for the group containing the message(s).messages- The messages to be removed.
-
completeGroup
Description copied from interface:MessageGroupStoreCompletes this MessageGroup. Completion of the MessageGroup generally means that this group should not be allowing any more 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 interfaceMessageGroupStore- Parameters:
groupId- The group identifier.
-
removeMessageGroup
Remove the MessageGroup with the provided group ID.- Specified by:
removeMessageGroupin interfaceBasicMessageGroupStore- Parameters:
groupId- The id of the group to remove.
-
setGroupCondition
Description 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 interfaceMessageGroupStore- Parameters:
groupId- The group identifier.condition- The condition to store into the group.
-
setLastReleasedSequenceNumberForGroup
Description copied from interface:MessageGroupStoreAllows you to set the sequence number of the last released Message. Used for Resequencing use cases- Specified by:
setLastReleasedSequenceNumberForGroupin interfaceMessageGroupStore- Parameters:
groupId- The group identifier.sequenceNumber- The sequence number.
-
pollMessageFromGroup
Description copied from interface:BasicMessageGroupStorePolls Message from thisMessageGroup(in FIFO style if supported by the implementation) while also removing the polledMessage- Specified by:
pollMessageFromGroupin interfaceBasicMessageGroupStore- Parameters:
groupId- The group identifier.- Returns:
- The message.
-
getOneMessageFromGroup
Description copied from interface:MessageGroupStoreReturn the oneMessagefromMessageGroup.- Specified by:
getOneMessageFromGroupin interfaceMessageGroupStore- Parameters:
groupId- The group identifier.- Returns:
- the
Message.
-
getMessagesForGroup
Description copied from interface:MessageGroupStoreRetrieve messages for the provided group id.- Specified by:
getMessagesForGroupin interfaceMessageGroupStore- Parameters:
groupId- The group id to retrieve messages for.- Returns:
- the messages for group.
-
streamMessagesForGroup
Description copied from interface:MessageGroupStoreReturn a stream for messages stored in the provided group.- Specified by:
streamMessagesForGroupin interfaceMessageGroupStore- Parameters:
groupId- the group id to retrieve messages.- Returns:
- the
Streamfor messages in this group.
-
iterator
- Specified by:
iteratorin interfaceIterable<MessageGroup>- Specified by:
iteratorin interfaceMessageGroupStore- Returns:
- The iterator of currently accumulated
MessageGroups.
-
messageGroupSize
Description copied from interface:BasicMessageGroupStoreReturns the size of this MessageGroup.- Specified by:
messageGroupSizein interfaceBasicMessageGroupStore- Parameters:
groupId- The group identifier.- Returns:
- The size.
-
doRetrieve
-
doStore
-
doStoreIfAbsent
-
doRemove
-
doRemoveAll
-
doListKeys
-