Class MemoryGroup

java.lang.Object
com.swiftmq.impl.streams.comp.memory.MemoryGroup

public class MemoryGroup extends Object
A MemoryGroup groups incoming Messages on base of the values of a Message Property (Group Property). Scripts register a MemoryCreateCallback that is called for each new value of this Property so that a Memory exists for each distinct Property value. The MemoryCreateCallback may also chose to not create a Memory and may return null. In that case the value will not be respected.

A MemoryGroup may be used to implement session windows.

Author:
IIT Software GmbH, Muenster/Germany, (c) 2017, All Rights Reserved
  • Constructor Details

  • Method Details

    • name

      public String name()
      Returns the name of this MemoryGroup
      Returns:
      name
    • groupPropertyName

      public String groupPropertyName()
      Returns the name of the group Property.
      Returns:
      group Property name
    • inactivityTimeout

      public GroupInactivityTimeout inactivityTimeout()
      Sets and returns the GroupInactivityTimeout for this Memory. A GroupInactivityTimeout can be attached to a MemoryGroup and specifies a time of inactivity (no adds to attached Memory) after which all Messages in that Memory will retire and the Memory will be closed and removed from the MemoryGroup. Inactivity is checked during MemoryGroup.checkLimit() and thus needs to be regularly called from a Timer.
      Returns:
      GroupInactivityTimeout
    • add

      public MemoryGroup add(Message message) throws Exception
      Adds a Message to this MemoryGroup. If the value of the group Property is detected for the first time, MemoryCreateCallback.create is called.
      Parameters:
      message - Message
      Returns:
      this
      Throws:
      Exception
    • onCreate

      public MemoryGroup onCreate(MemoryCreateCallback callback)
      Registers a MemoryCreateCallback (mandatory)
      Parameters:
      callback - MemoryCreateCallback
      Returns:
      this
    • onRemove

      public MemoryGroup onRemove(MemoryRemoveCallback callback)
      Registers a MemoryRemoveCallback (optional)
      Parameters:
      callback - MemoryRemoveCallback
      Returns:
      this
    • removeMemory

      public MemoryGroup removeMemory(Comparable key)
      Removes a Memory from this MemoryGroup.
      Parameters:
      key - Value of the group Property
      Returns:
      this
    • checkLimit

      public MemoryGroup checkLimit()
      Checks inactivity and calls checkLimit() on each Memory of this MemoryGroup
      Returns:
      this
    • forEach

      public void forEach(ForEachMemoryCallback callback)
      Executes the Callback for each Memory in this MemoryGroup
      Parameters:
      callback - Callback
      Throws:
      Exception
    • deferredClose

      public void deferredClose()
      Internal Use.
    • isMarkedAsClose

      public boolean isMarkedAsClose()
      Internal Use.
    • close

      public void close()
      Closes this MemoryGroup. It closes also all Memories attached to this MemoryGroup
    • toString

      public String toString()
      Overrides:
      toString in class Object