Interface MessageGroupStore

All Superinterfaces:
BasicMessageGroupStore
All Known Implementing Classes:
AbstractConfigurableMongoDbMessageStore, AbstractKeyValueMessageStore, AbstractMessageGroupStore, ConfigurableMongoDbMessageStore, HazelcastMessageStore, JdbcMessageStore, MongoDbChannelMessageStore, MongoDbMessageStore, RedisMessageStore, SimpleMessageStore

public interface MessageGroupStore extends BasicMessageGroupStore
Defines additional storage operations on groups of messages linked by a group id.
Since:
2.0
Author:
Dave Syer, Oleg Zhurakousky, Gary Russell, Artem Bilan
  • Method Details

    • getMessageCountForAllMessageGroups

      @ManagedAttribute int getMessageCountForAllMessageGroups()
      Optional attribute giving the number of messages in the store over all groups. Implementations may decline to respond by throwing an exception.
      Returns:
      the number of messages
      Throws:
      UnsupportedOperationException - if not implemented
    • getMessageGroupCount

      @ManagedAttribute int getMessageGroupCount()
      Optional attribute giving the number of message groups. Implementations may decline to respond by throwing an exception.
      Returns:
      the number message groups
      Throws:
      UnsupportedOperationException - if not implemented
    • removeMessagesFromGroup

      void removeMessagesFromGroup(Object key, Collection<Message<?>> messages)
      Persist the deletion of messages from the group.
      Parameters:
      key - The groupId for the group containing the message(s).
      messages - The messages to be removed.
      Since:
      4.2
    • removeMessagesFromGroup

      void removeMessagesFromGroup(Object key, Message<?>... messages)
      Persist the deletion of messages from the group.
      Parameters:
      key - The groupId for the group containing the message(s).
      messages - The messages to be removed.
      Since:
      4.2
    • registerMessageGroupExpiryCallback

      void registerMessageGroupExpiryCallback(MessageGroupStore.MessageGroupCallback callback)
      Register a callback for when a message group is expired through expireMessageGroups(long).
      Parameters:
      callback - A callback to execute when a message group is cleaned up.
    • expireMessageGroups

      @ManagedOperation int expireMessageGroups(long timeout)
      Extract all expired groups (whose timestamp is older than the current time less the threshold provided) and call each of the registered callbacks on them in turn. For example: call with a timeout of 100 to expire all groups that were created more than 100 milliseconds ago, and are not yet complete. Use a timeout of 0 (or negative to be on the safe side) to expire all message groups.
      Parameters:
      timeout - the timeout threshold to use
      Returns:
      the number of message groups expired
      See Also:
    • setLastReleasedSequenceNumberForGroup

      void setLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber)
      Allows you to set the sequence number of the last released Message. Used for Resequencing use cases
      Parameters:
      groupId - The group identifier.
      sequenceNumber - The sequence number.
    • setGroupCondition

      void setGroupCondition(Object groupId, String condition)
      Add 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.
      Parameters:
      groupId - The group identifier.
      condition - The condition to store into the group.
      Since:
      5.5
    • iterator

      Iterator<MessageGroup> iterator()
      Returns:
      The iterator of currently accumulated MessageGroups.
    • completeGroup

      void completeGroup(Object groupId)
      Completes 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.
      Parameters:
      groupId - The group identifier.
    • getGroupMetadata

      MessageGroupMetadata getGroupMetadata(Object groupId)
      Obtain the group metadata without fetching any messages; must supply all other group properties; may include the id of the first message.
      Parameters:
      groupId - The group id.
      Returns:
      The metadata.
      Since:
      4.0
    • getOneMessageFromGroup

      Message<?> getOneMessageFromGroup(Object groupId)
      Return the one Message from MessageGroup.
      Parameters:
      groupId - The group identifier.
      Returns:
      the Message.
      Since:
      4.0
    • addMessagesToGroup

      void addMessagesToGroup(Object groupId, Message<?>... messages)
      Store messages with an association to a group id. This can be used to group messages together.
      Parameters:
      groupId - The group id to store messages under.
      messages - The messages to add.
      Since:
      4.3
    • getMessagesForGroup

      Collection<Message<?>> getMessagesForGroup(Object groupId)
      Retrieve messages for the provided group id.
      Parameters:
      groupId - The group id to retrieve messages for.
      Returns:
      the messages for group.
      Since:
      4.3
    • streamMessagesForGroup

      default Stream<Message<?>> streamMessagesForGroup(Object groupId)
      Return 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 of getMessagesForGroup(Object).
      Parameters:
      groupId - the group id to retrieve messages.
      Returns:
      the Stream for messages in this group.
      Since:
      5.5