Class MongoDbMessageStore

java.lang.Object
org.springframework.integration.store.AbstractBatchingMessageGroupStore
org.springframework.integration.store.AbstractMessageGroupStore
org.springframework.integration.mongodb.store.MongoDbMessageStore
All Implemented Interfaces:
java.lang.Iterable<org.springframework.integration.store.MessageGroup>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.integration.store.BasicMessageGroupStore, org.springframework.integration.store.MessageGroupStore, org.springframework.integration.store.MessageStore

public class MongoDbMessageStore
extends org.springframework.integration.store.AbstractMessageGroupStore
implements org.springframework.integration.store.MessageStore, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
An implementation of both the MessageStore and MessageGroupStore strategies that relies upon MongoDB for persistence.
Since:
2.1
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.springframework.integration.store.MessageGroupStore

    org.springframework.integration.store.MessageGroupStore.MessageGroupCallback
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String SEQUENCE_NAME  

    Fields inherited from class org.springframework.integration.store.AbstractMessageGroupStore

    logger
  • Constructor Summary

    Constructors 
    Constructor Description
    MongoDbMessageStore​(org.springframework.data.mongodb.MongoDatabaseFactory mongoDbFactory)
    Create a MongoDbMessageStore using the provided MongoDatabaseFactory.and the default collection name.
    MongoDbMessageStore​(org.springframework.data.mongodb.MongoDatabaseFactory mongoDbFactory, java.lang.String collectionName)
    Create a MongoDbMessageStore using the provided MongoDatabaseFactory and collection name.
  • Method Summary

    Modifier and Type Method Description
    void addAllowedPatterns​(java.lang.String... patterns)
    Add patterns for packages/classes that are allowed to be deserialized.
    <T> org.springframework.messaging.Message<T> addMessage​(org.springframework.messaging.Message<T> message)  
    void addMessagesToGroup​(java.lang.Object groupId, org.springframework.messaging.Message<?>... messages)  
    void afterPropertiesSet()  
    void completeGroup​(java.lang.Object groupId)  
    org.springframework.messaging.Message<?> getMessage​(java.util.UUID id)  
    long getMessageCount()  
    int getMessageCountForAllMessageGroups()  
    org.springframework.integration.store.MessageGroup getMessageGroup​(java.lang.Object groupId)  
    int getMessageGroupCount()  
    org.springframework.integration.store.MessageMetadata getMessageMetadata​(java.util.UUID id)  
    java.util.Collection<org.springframework.messaging.Message<?>> getMessagesForGroup​(java.lang.Object groupId)  
    org.springframework.messaging.Message<?> getOneMessageFromGroup​(java.lang.Object groupId)  
    java.util.Iterator<org.springframework.integration.store.MessageGroup> iterator()  
    int messageGroupSize​(java.lang.Object groupId)  
    org.springframework.messaging.Message<?> pollMessageFromGroup​(java.lang.Object groupId)  
    org.springframework.messaging.Message<?> removeMessage​(java.util.UUID id)  
    void removeMessageGroup​(java.lang.Object groupId)  
    void removeMessagesFromGroup​(java.lang.Object groupId, java.util.Collection<org.springframework.messaging.Message<?>> messages)  
    void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)  
    void setBeanClassLoader​(java.lang.ClassLoader classLoader)  
    void setCustomConverters​(java.lang.Object... customConverters)
    Configure a set of converters to use in the MappingMongoConverter.
    void setLastReleasedSequenceNumberForGroup​(java.lang.Object groupId, int sequenceNumber)  
    java.util.stream.Stream<org.springframework.messaging.Message<?>> streamMessagesForGroup​(java.lang.Object groupId)  

    Methods inherited from class org.springframework.integration.store.AbstractMessageGroupStore

    addMessageToGroup, copy, expireMessageGroups, getGroupMetadata, getMessageGroupFactory, isTimeoutOnIdle, registerMessageGroupExpiryCallback, removeMessagesFromGroup, setExpiryCallbacks, setLazyLoadMessageGroups, setTimeoutOnIdle

    Methods inherited from class org.springframework.integration.store.AbstractBatchingMessageGroupStore

    getRemoveBatchSize, setMessageGroupFactory, setRemoveBatchSize

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

  • Constructor Details

    • MongoDbMessageStore

      public MongoDbMessageStore​(org.springframework.data.mongodb.MongoDatabaseFactory mongoDbFactory)
      Create a MongoDbMessageStore using the provided MongoDatabaseFactory.and the default collection name.
      Parameters:
      mongoDbFactory - The mongodb factory.
    • MongoDbMessageStore

      public MongoDbMessageStore​(org.springframework.data.mongodb.MongoDatabaseFactory mongoDbFactory, @Nullable java.lang.String collectionName)
      Create a MongoDbMessageStore using the provided MongoDatabaseFactory and collection name.
      Parameters:
      mongoDbFactory - The mongodb factory.
      collectionName - The collection name.
  • Method Details

    • setBeanClassLoader

      public void setBeanClassLoader​(java.lang.ClassLoader classLoader)
      Specified by:
      setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware
    • setApplicationContext

      public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • addAllowedPatterns

      public void addAllowedPatterns​(java.lang.String... patterns)
      Add patterns for packages/classes that are allowed to be deserialized. A class can be fully qualified or a wildcard '*' is allowed at the beginning or end of the class name. Examples: com.foo.*, *.MyClass.
      Parameters:
      patterns - the patterns.
      Since:
      5.4
    • setCustomConverters

      public void setCustomConverters​(java.lang.Object... customConverters)
      Configure a set of converters to use in the MappingMongoConverter. Must be instances of org.springframework.core.convert.converter.Converter, org.springframework.core.convert.converter.ConverterFactory, org.springframework.core.convert.converter.GenericConverter or org.springframework.data.convert.ConverterBuilder.ConverterAware.
      Parameters:
      customConverters - the converters to use.
      Since:
      5.1.6
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • addMessage

      public <T> org.springframework.messaging.Message<T> addMessage​(org.springframework.messaging.Message<T> message)
      Specified by:
      addMessage in interface org.springframework.integration.store.MessageStore
    • getMessage

      public org.springframework.messaging.Message<?> getMessage​(java.util.UUID id)
      Specified by:
      getMessage in interface org.springframework.integration.store.MessageStore
    • getMessageMetadata

      public org.springframework.integration.store.MessageMetadata getMessageMetadata​(java.util.UUID id)
      Specified by:
      getMessageMetadata in interface org.springframework.integration.store.MessageStore
    • getMessageCount

      @ManagedAttribute public long getMessageCount()
      Specified by:
      getMessageCount in interface org.springframework.integration.store.MessageStore
    • removeMessage

      public org.springframework.messaging.Message<?> removeMessage​(java.util.UUID id)
      Specified by:
      removeMessage in interface org.springframework.integration.store.MessageStore
    • getMessageGroup

      public org.springframework.integration.store.MessageGroup getMessageGroup​(java.lang.Object groupId)
      Specified by:
      getMessageGroup in interface org.springframework.integration.store.BasicMessageGroupStore
    • addMessagesToGroup

      public void addMessagesToGroup​(java.lang.Object groupId, org.springframework.messaging.Message<?>... messages)
      Specified by:
      addMessagesToGroup in interface org.springframework.integration.store.MessageGroupStore
    • removeMessagesFromGroup

      public void removeMessagesFromGroup​(java.lang.Object groupId, java.util.Collection<org.springframework.messaging.Message<?>> messages)
      Specified by:
      removeMessagesFromGroup in interface org.springframework.integration.store.MessageGroupStore
    • removeMessageGroup

      public void removeMessageGroup​(java.lang.Object groupId)
      Specified by:
      removeMessageGroup in interface org.springframework.integration.store.BasicMessageGroupStore
    • iterator

      public java.util.Iterator<org.springframework.integration.store.MessageGroup> iterator()
      Specified by:
      iterator in interface java.lang.Iterable<org.springframework.integration.store.MessageGroup>
      Specified by:
      iterator in interface org.springframework.integration.store.MessageGroupStore
    • pollMessageFromGroup

      public org.springframework.messaging.Message<?> pollMessageFromGroup​(java.lang.Object groupId)
      Specified by:
      pollMessageFromGroup in interface org.springframework.integration.store.BasicMessageGroupStore
    • messageGroupSize

      public int messageGroupSize​(java.lang.Object groupId)
      Specified by:
      messageGroupSize in interface org.springframework.integration.store.BasicMessageGroupStore
    • setLastReleasedSequenceNumberForGroup

      public void setLastReleasedSequenceNumberForGroup​(java.lang.Object groupId, int sequenceNumber)
      Specified by:
      setLastReleasedSequenceNumberForGroup in interface org.springframework.integration.store.MessageGroupStore
    • completeGroup

      public void completeGroup​(java.lang.Object groupId)
      Specified by:
      completeGroup in interface org.springframework.integration.store.MessageGroupStore
    • getOneMessageFromGroup

      public org.springframework.messaging.Message<?> getOneMessageFromGroup​(java.lang.Object groupId)
      Specified by:
      getOneMessageFromGroup in interface org.springframework.integration.store.MessageGroupStore
    • getMessagesForGroup

      public java.util.Collection<org.springframework.messaging.Message<?>> getMessagesForGroup​(java.lang.Object groupId)
      Specified by:
      getMessagesForGroup in interface org.springframework.integration.store.MessageGroupStore
    • streamMessagesForGroup

      public java.util.stream.Stream<org.springframework.messaging.Message<?>> streamMessagesForGroup​(java.lang.Object groupId)
      Specified by:
      streamMessagesForGroup in interface org.springframework.integration.store.MessageGroupStore
    • getMessageCountForAllMessageGroups

      @ManagedAttribute public int getMessageCountForAllMessageGroups()
      Specified by:
      getMessageCountForAllMessageGroups in interface org.springframework.integration.store.MessageGroupStore
      Overrides:
      getMessageCountForAllMessageGroups in class org.springframework.integration.store.AbstractMessageGroupStore
    • getMessageGroupCount

      @ManagedAttribute public int getMessageGroupCount()
      Specified by:
      getMessageGroupCount in interface org.springframework.integration.store.MessageGroupStore
      Overrides:
      getMessageGroupCount in class org.springframework.integration.store.AbstractMessageGroupStore