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, Youbin Wu
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.store.MessageGroupStoreMessageGroupStore.MessageGroupCallback
- 
Field SummaryFieldsFields inherited from class org.springframework.integration.mongodb.store.AbstractConfigurableMongoDbMessageStorecollectionName, logger, mongoDbFactory, SEQUENCE_NAMEFields inherited from class org.springframework.integration.store.AbstractMessageGroupStoreINTERRUPTED_WHILE_OBTAINING_LOCK
- 
Constructor SummaryConstructorsConstructorDescriptionConfigurableMongoDbMessageStore(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 SummaryModifier and TypeMethodDescription<T> Message<T>addMessage(Message<T> message) Put the provided Message into the MessageStore.addMessageToGroup(Object groupId, Message<?> message) Store a message with an association to a group id.protected voiddoAddMessagesToGroup(Object groupId, Message<?>... messages) protected voiddoCompleteGroup(Object groupId) protected Message<?>doPollMessageFromGroup(Object groupId) protected booleandoRemoveMessageFromGroupById(Object groupId, UUID messageId) protected voiddoRemoveMessagesFromGroup(Object groupId, Collection<Message<?>> messages) protected voiddoSetGroupCondition(Object groupId, String condition) protected voiddoSetLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber) 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<?>removeMessage(UUID id) Remove the Message with the given id from the MessageStore, if present, and return it.streamMessagesForGroup(Object groupId) Return a stream for messages stored in the provided group.Methods inherited from class org.springframework.integration.mongodb.store.AbstractConfigurableMongoDbMessageStoreaddMessageDocument, afterPropertiesSet, createIndexes, doRemoveMessageGroup, getApplicationContext, getMappingMongoConverter, getMessage, getMessageBuilderFactory, getMessageMetadata, getMongoTemplate, getNextId, groupIdQuery, messageGroupSize, setApplicationContext, setCreateIndexesMethods inherited from class org.springframework.integration.store.AbstractMessageGroupStoreaddMessagesToGroup, completeGroup, copy, executeLocked, executeLocked, expireMessageGroups, getGroupMetadata, getLockRegistry, getMessageGroupFactory, isTimeoutOnIdle, pollMessageFromGroup, registerMessageGroupExpiryCallback, removeMessageFromGroupById, removeMessageGroup, removeMessagesFromGroup, removeMessagesFromGroup, setExpiryCallbacks, setGroupCondition, setLastReleasedSequenceNumberForGroup, setLazyLoadMessageGroups, 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 java.lang.IterableforEach, spliteratorMethods inherited from interface org.springframework.integration.store.MessageStoregetMessage, getMessageMetadata
- 
Field Details- 
DEFAULT_COLLECTION_NAME- See Also:
 
 
- 
- 
Constructor Details- 
ConfigurableMongoDbMessageStore
- 
ConfigurableMongoDbMessageStore
- 
ConfigurableMongoDbMessageStore
- 
ConfigurableMongoDbMessageStorepublic ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter) 
- 
ConfigurableMongoDbMessageStore
- 
ConfigurableMongoDbMessageStorepublic ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter, String collectionName) 
 
- 
- 
Method Details- 
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.
 
- 
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:
- id- the message identifier.
- Returns:
- the message (if any).
 
- 
getMessageCountpublic 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 interface- MessageStore
- Returns:
- The number of messages.
 
- 
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.
 
- 
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
- Overrides:
- addMessageToGroupin class- AbstractMessageGroupStore
- Parameters:
- groupId- The group id to store the message under.
- message- A message.
- Returns:
- The message group.
 
- 
doAddMessagesToGroup- Overrides:
- doAddMessagesToGroupin class- AbstractConfigurableMongoDbMessageStore
 
- 
doRemoveMessagesFromGroup- Overrides:
- doRemoveMessagesFromGroupin class- AbstractConfigurableMongoDbMessageStore
 
- 
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
 
- 
doPollMessageFromGroup- Specified by:
- doPollMessageFromGroupin class- AbstractMessageGroupStore
 
- 
doSetLastReleasedSequenceNumberForGroup- Overrides:
- doSetLastReleasedSequenceNumberForGroupin class- AbstractConfigurableMongoDbMessageStore
 
- 
doSetGroupCondition- Overrides:
- doSetGroupConditionin class- AbstractConfigurableMongoDbMessageStore
 
- 
doCompleteGroup- Overrides:
- doCompleteGroupin class- AbstractConfigurableMongoDbMessageStore
 
- 
iterator- Specified by:
- iteratorin interface- Iterable<MessageGroup>
- Specified by:
- iteratorin interface- MessageGroupStore
- Overrides:
- iteratorin class- AbstractConfigurableMongoDbMessageStore
- Returns:
- The iterator of currently accumulated MessageGroups.
 
- 
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
- Overrides:
- getMessageCountForAllMessageGroupsin class- AbstractMessageGroupStore
- 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
- Overrides:
- getMessageGroupCountin class- AbstractMessageGroupStore
- Returns:
- the number message groups
 
- 
getOneMessageFromGroupDescription copied from interface:MessageGroupStoreReturn the oneMessagefromMessageGroup.- Specified by:
- getOneMessageFromGroupin interface- MessageGroupStore
- Overrides:
- getOneMessageFromGroupin class- AbstractConfigurableMongoDbMessageStore
- Parameters:
- groupId- The group identifier.
- Returns:
- the Message.
 
- 
getMessagesForGroupDescription copied from interface:MessageGroupStoreRetrieve messages for the provided group id.- Specified by:
- getMessagesForGroupin interface- MessageGroupStore
- Overrides:
- getMessagesForGroupin class- AbstractConfigurableMongoDbMessageStore
- Parameters:
- groupId- The group id to retrieve messages for.
- Returns:
- the messages for group.
 
- 
streamMessagesForGroupDescription 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 interface- MessageGroupStore
- Parameters:
- groupId- the group id to retrieve messages.
- Returns:
- the Streamfor messages in this group.
 
 
-