Class ConfigurableMongoDbMessageStore
java.lang.Object
org.springframework.integration.store.AbstractBatchingMessageGroupStore
org.springframework.integration.store.AbstractMessageGroupStore
org.springframework.integration.mongodb.store.AbstractConfigurableMongoDbMessageStore
org.springframework.integration.mongodb.store.ConfigurableMongoDbMessageStore
- All Implemented Interfaces:
Iterable<MessageGroup>,Aware,InitializingBean,ApplicationContextAware,BasicMessageGroupStore,MessageGroupStore,MessageStore
public class ConfigurableMongoDbMessageStore
extends AbstractConfigurableMongoDbMessageStore
implements MessageStore
An alternate MongoDB
MessageStore and
MessageGroupStore which allows the user to
configure the instance of MongoTemplate. The mechanism of storing the messages/group of messages
in the store is and is different from MongoDbMessageStore. Since the store uses serialization of the
messages by default, all the headers, and the payload of the Message must implement Serializable
interface- Since:
- 3.0
- Author:
- Amol Nayak, Artem Bilan, Gary Russell, Ngoc Nhan
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.store.MessageGroupStore
MessageGroupStore.MessageGroupCallback -
Field Summary
FieldsFields inherited from class org.springframework.integration.mongodb.store.AbstractConfigurableMongoDbMessageStore
collectionName, logger, mongoDbFactory, SEQUENCE_NAME -
Constructor Summary
ConstructorsConstructorDescriptionConfigurableMongoDbMessageStore(MongoTemplate mongoTemplate) ConfigurableMongoDbMessageStore(MongoTemplate mongoTemplate, String collectionName) ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory) ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, String collectionName) ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter) ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter, String collectionName) -
Method Summary
Modifier 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.addMessageToGroup(Object groupId, Message<?> message) Store a message with an association to a group id.voidcompleteGroup(Object groupId) Completes this MessageGroup.longOptional attribute giving the number of messages in the store.intOptional attribute giving the number of messages in the store over all groups.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.intOptional 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 oneMessagefromMessageGroup.iterator()Message<?>pollMessageFromGroup(Object groupId) Poll Message from thisMessageGroup(in FIFO style if supported by the implementation) while also removing the polledMessage.Message<?>removeMessage(UUID id) Remove the Message with the given id from the MessageStore, if present, and return it.booleanremoveMessageFromGroupById(Object groupId, UUID messageId) Deletion the message from the group.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.streamMessagesForGroup(Object groupId) Return a stream for messages stored in the provided group.Methods inherited from class org.springframework.integration.mongodb.store.AbstractConfigurableMongoDbMessageStore
addMessageDocument, afterPropertiesSet, createIndexes, getApplicationContext, getMappingMongoConverter, getMessage, getMessageBuilderFactory, getMessageMetadata, getMongoTemplate, getNextId, groupIdQuery, messageGroupSize, removeMessageGroup, setApplicationContext, setCreateIndexesMethods inherited from class org.springframework.integration.store.AbstractMessageGroupStore
copy, expireMessageGroups, getGroupMetadata, getMessageGroupFactory, isTimeoutOnIdle, registerMessageGroupExpiryCallback, removeMessagesFromGroup, setExpiryCallbacks, setLazyLoadMessageGroups, setTimeoutOnIdleMethods inherited from class org.springframework.integration.store.AbstractBatchingMessageGroupStore
getRemoveBatchSize, setMessageGroupFactory, setRemoveBatchSizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.springframework.integration.store.MessageStore
getMessage, getMessageMetadata
-
Field Details
-
DEFAULT_COLLECTION_NAME
- See Also:
-
-
Constructor Details
-
ConfigurableMongoDbMessageStore
-
ConfigurableMongoDbMessageStore
-
ConfigurableMongoDbMessageStore
-
ConfigurableMongoDbMessageStore
public ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter) -
ConfigurableMongoDbMessageStore
-
ConfigurableMongoDbMessageStore
public ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter, String collectionName)
-
-
Method Details
-
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.
-
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 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 interfaceMessageStore- Parameters:
id- the message identifier.- Returns:
- the message (if any).
-
getMessageCount
public long 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
Description copied from interface:BasicMessageGroupStoreReturn all Messages currently in the MessageStore that were stored usingBasicMessageGroupStore.addMessageToGroup(Object, Message)with this group id.- Specified by:
getMessageGroupin interfaceBasicMessageGroupStore- Parameters:
groupId- The group identifier.- Returns:
- A group of messages, empty if none exists for this key.
-
addMessageToGroup
Description copied from interface:BasicMessageGroupStoreStore a message with an association to a group id. This can be used to group messages together.- Specified by:
addMessageToGroupin interfaceBasicMessageGroupStore- Overrides:
addMessageToGroupin classAbstractMessageGroupStore- Parameters:
groupId- The group id to store the message under.message- A message.- Returns:
- The message group.
-
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- Overrides:
addMessagesToGroupin classAbstractConfigurableMongoDbMessageStore- 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- Overrides:
removeMessagesFromGroupin classAbstractConfigurableMongoDbMessageStore- Parameters:
groupId- The groupId for the group containing the message(s).messages- The messages to be removed.
-
getMessageFromGroup
Description copied from interface:MessageGroupStoreRetrieve aMessagefrom a group by id. Returnnullif message does not belong to the requested group.- Specified by:
getMessageFromGroupin interfaceMessageGroupStore- Parameters:
groupId- The groupId for the group containing the message.messageId- The message id.- Returns:
- message by id if it belongs to requested group.
-
removeMessageFromGroupById
Description copied from interface:MessageGroupStoreDeletion the message from the group.- Specified by:
removeMessageFromGroupByIdin interfaceMessageGroupStore- Parameters:
groupId- The groupId for the group containing the message.messageId- The message id to be removed.- Returns:
- true if message has been removed.
-
pollMessageFromGroup
Description copied from interface:BasicMessageGroupStorePoll 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.
-
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- Overrides:
setLastReleasedSequenceNumberForGroupin classAbstractConfigurableMongoDbMessageStore- Parameters:
groupId- The group identifier.sequenceNumber- The sequence number.
-
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- Overrides:
setGroupConditionin classAbstractConfigurableMongoDbMessageStore- Parameters:
groupId- The group identifier.condition- The condition to store into the group.
-
completeGroup
Description 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 interfaceMessageGroupStore- Overrides:
completeGroupin classAbstractConfigurableMongoDbMessageStore- Parameters:
groupId- The group identifier.
-
iterator
- Specified by:
iteratorin interfaceIterable<MessageGroup>- Specified by:
iteratorin interfaceMessageGroupStore- Overrides:
iteratorin classAbstractConfigurableMongoDbMessageStore- Returns:
- The iterator of currently accumulated
MessageGroups.
-
getMessageCountForAllMessageGroups
Description 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 interfaceMessageGroupStore- Overrides:
getMessageCountForAllMessageGroupsin classAbstractMessageGroupStore- Returns:
- the number of messages
-
getMessageGroupCount
Description copied from interface:MessageGroupStoreOptional attribute giving the number of message groups. Implementations may decline to respond by throwing an exception.- Specified by:
getMessageGroupCountin interfaceMessageGroupStore- Overrides:
getMessageGroupCountin classAbstractMessageGroupStore- Returns:
- the number message groups
-
getOneMessageFromGroup
Description copied from interface:MessageGroupStoreReturn the oneMessagefromMessageGroup.- Specified by:
getOneMessageFromGroupin interfaceMessageGroupStore- Overrides:
getOneMessageFromGroupin classAbstractConfigurableMongoDbMessageStore- Parameters:
groupId- The group identifier.- Returns:
- the
Message.
-
getMessagesForGroup
Description copied from interface:MessageGroupStoreRetrieve messages for the provided group id.- Specified by:
getMessagesForGroupin interfaceMessageGroupStore- Overrides:
getMessagesForGroupin classAbstractConfigurableMongoDbMessageStore- 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. 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 ofMessageGroupStore.getMessagesForGroup(Object).- Specified by:
streamMessagesForGroupin interfaceMessageGroupStore- Parameters:
groupId- the group id to retrieve messages.- Returns:
- the
Streamfor messages in this group.
-