Class MemoryGroup
java.lang.Object
com.swiftmq.impl.streams.comp.memory.MemoryGroup
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 Summary
ConstructorDescriptionMemoryGroup
(StreamContext ctx, String name, String groupPropName) Internal use only. -
Method Summary
Modifier and TypeMethodDescriptionAdds a Message to this MemoryGroup.Checks inactivity and calls checkLimit() on each Memory of this MemoryGroupvoid
close()
Closes this MemoryGroup.void
Internal Use.void
forEach
(ForEachMemoryCallback callback) Executes the Callback for each Memory in this MemoryGroupReturns the name of the group Property.Sets and returns the GroupInactivityTimeout for this Memory.boolean
Internal Use.name()
Returns the name of this MemoryGrouponCreate
(MemoryCreateCallback callback) Registers a MemoryCreateCallback (mandatory)onRemove
(MemoryRemoveCallback callback) Registers a MemoryRemoveCallback (optional)removeMemory
(Comparable key) Removes a Memory from this MemoryGroup.toString()
-
Constructor Details
-
MemoryGroup
Internal use only.
-
-
Method Details
-
name
Returns the name of this MemoryGroup- Returns:
- name
-
groupPropertyName
Returns the name of the group Property.- Returns:
- group Property name
-
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
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
Registers a MemoryCreateCallback (mandatory)- Parameters:
callback
- MemoryCreateCallback- Returns:
- this
-
onRemove
Registers a MemoryRemoveCallback (optional)- Parameters:
callback
- MemoryRemoveCallback- Returns:
- this
-
removeMemory
Removes a Memory from this MemoryGroup.- Parameters:
key
- Value of the group Property- Returns:
- this
-
checkLimit
Checks inactivity and calls checkLimit() on each Memory of this MemoryGroup- Returns:
- this
-
forEach
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
-