Class SimpleMessageGroup

java.lang.Object
org.springframework.integration.store.SimpleMessageGroup
All Implemented Interfaces:
MessageGroup
Direct Known Subclasses:
AbstractCorrelatingMessageHandler.SequenceAwareMessageGroup

public class SimpleMessageGroup
extends java.lang.Object
implements MessageGroup
Represents a mutable group of correlated messages that is bound to a certain MessageStore and group id. The group will grow during its lifetime, when messages are add(org.springframework.messaging.Message<?>)ed to it. This MessageGroup is thread safe.
Since:
2.0
  • Constructor Summary

    Constructors 
    Constructor Description
    SimpleMessageGroup​(java.lang.Object groupId)  
    SimpleMessageGroup​(java.util.Collection<? extends org.springframework.messaging.Message<?>> messages, java.lang.Object groupId)  
    SimpleMessageGroup​(java.util.Collection<? extends org.springframework.messaging.Message<?>> messages, java.lang.Object groupId, long timestamp, boolean complete)  
    SimpleMessageGroup​(java.util.Collection<org.springframework.messaging.Message<?>> internalStore, java.util.Collection<? extends org.springframework.messaging.Message<?>> messages, java.lang.Object groupId, long timestamp, boolean complete, boolean storePreLoaded)  
    SimpleMessageGroup​(MessageGroup messageGroup)  
  • Method Summary

    Modifier and Type Method Description
    void add​(org.springframework.messaging.Message<?> messageToAdd)
    Add the message to this group.
    boolean canAdd​(org.springframework.messaging.Message<?> message)
    Query if the message can be added.
    void clear()  
    void complete()
    Complete the group.
    boolean containsSequence​(java.lang.Integer sequence)
    Return true if a message with this sequence number header exists in the group.
    java.lang.String getCondition()
    Return the condition for this group to consult with, e.g.
    java.lang.Object getGroupId()  
    long getLastModified()  
    int getLastReleasedMessageSequenceNumber()  
    java.util.Collection<org.springframework.messaging.Message<?>> getMessages()
    Return all available Messages from the group at the time of invocation.
    org.springframework.messaging.Message<?> getOne()  
    int getSequenceSize()  
    long getTimestamp()  
    boolean isComplete()  
    boolean remove​(org.springframework.messaging.Message<?> message)
    Remove the message from this group.
    void setCondition​(java.lang.String condition)
    Add a condition statement to this group which can be consulted later on, e.g.
    void setLastModified​(long lastModified)  
    void setLastReleasedMessageSequenceNumber​(int sequenceNumber)  
    int size()  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.springframework.integration.store.MessageGroup

    streamMessages
  • Constructor Details

    • SimpleMessageGroup

      public SimpleMessageGroup​(java.lang.Object groupId)
    • SimpleMessageGroup

      public SimpleMessageGroup​(java.util.Collection<? extends org.springframework.messaging.Message<?>> messages, java.lang.Object groupId)
    • SimpleMessageGroup

      public SimpleMessageGroup​(MessageGroup messageGroup)
    • SimpleMessageGroup

      public SimpleMessageGroup​(java.util.Collection<? extends org.springframework.messaging.Message<?>> messages, java.lang.Object groupId, long timestamp, boolean complete)
    • SimpleMessageGroup

      public SimpleMessageGroup​(java.util.Collection<org.springframework.messaging.Message<?>> internalStore, java.util.Collection<? extends org.springframework.messaging.Message<?>> messages, java.lang.Object groupId, long timestamp, boolean complete, boolean storePreLoaded)
  • Method Details

    • getTimestamp

      public long getTimestamp()
      Specified by:
      getTimestamp in interface MessageGroup
      Returns:
      the timestamp (milliseconds since epoch) associated with the creation of this group
    • setLastModified

      public void setLastModified​(long lastModified)
      Specified by:
      setLastModified in interface MessageGroup
    • getLastModified

      public long getLastModified()
      Specified by:
      getLastModified in interface MessageGroup
      Returns:
      the timestamp (milliseconds since epoch) associated with the time this group was last updated
    • canAdd

      public boolean canAdd​(org.springframework.messaging.Message<?> message)
      Description copied from interface: MessageGroup
      Query if the message can be added.
      Specified by:
      canAdd in interface MessageGroup
      Parameters:
      message - The message.
      Returns:
      true if the message can be added.
    • add

      public void add​(org.springframework.messaging.Message<?> messageToAdd)
      Description copied from interface: MessageGroup
      Add the message to this group.
      Specified by:
      add in interface MessageGroup
      Parameters:
      messageToAdd - the message to add.
    • remove

      public boolean remove​(org.springframework.messaging.Message<?> message)
      Description copied from interface: MessageGroup
      Remove the message from this group.
      Specified by:
      remove in interface MessageGroup
      Parameters:
      message - the message to remove.
      Returns:
      true if a message was removed.
    • getLastReleasedMessageSequenceNumber

      public int getLastReleasedMessageSequenceNumber()
      Specified by:
      getLastReleasedMessageSequenceNumber in interface MessageGroup
      Returns:
      the sequenceNumber of the last released message. Used in Resequencer use cases only
    • getMessages

      public java.util.Collection<org.springframework.messaging.Message<?>> getMessages()
      Description copied from interface: MessageGroup
      Return all available Messages from the group at the time of invocation.
      Specified by:
      getMessages in interface MessageGroup
      Returns:
      The messages.
    • setLastReleasedMessageSequenceNumber

      public void setLastReleasedMessageSequenceNumber​(int sequenceNumber)
      Specified by:
      setLastReleasedMessageSequenceNumber in interface MessageGroup
    • getGroupId

      public java.lang.Object getGroupId()
      Specified by:
      getGroupId in interface MessageGroup
      Returns:
      the key that links these messages together
    • isComplete

      public boolean isComplete()
      Specified by:
      isComplete in interface MessageGroup
      Returns:
      true if the group is complete (i.e. no more messages are expected to be added)
    • complete

      public void complete()
      Description copied from interface: MessageGroup
      Complete the group.
      Specified by:
      complete in interface MessageGroup
    • getSequenceSize

      public int getSequenceSize()
      Specified by:
      getSequenceSize in interface MessageGroup
      Returns:
      the size of the sequence expected 0 if unknown
    • size

      public int size()
      Specified by:
      size in interface MessageGroup
      Returns:
      the total number of messages in this group
    • setCondition

      public void setCondition​(java.lang.String condition)
      Description copied from interface: MessageGroup
      Add a condition statement to this group which can be consulted later on, e.g. from the release strategy.
      Specified by:
      setCondition in interface MessageGroup
      Parameters:
      condition - statement which could be consulted later on, e.g. from the release strategy.
    • getCondition

      @Nullable public java.lang.String getCondition()
      Description copied from interface: MessageGroup
      Return the condition for this group to consult with, e.g. from the release strategy.
      Specified by:
      getCondition in interface MessageGroup
      Returns:
      the condition for this group to consult with, e.g. from the release strategy.
    • getOne

      public org.springframework.messaging.Message<?> getOne()
      Specified by:
      getOne in interface MessageGroup
      Returns:
      a single message from the group
    • clear

      public void clear()
      Specified by:
      clear in interface MessageGroup
    • containsSequence

      public boolean containsSequence​(java.lang.Integer sequence)
      Return true if a message with this sequence number header exists in the group.
      Parameters:
      sequence - the sequence number.
      Returns:
      true if it exists.
      Since:
      4.3.7
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object