Interface MessageGroup
- All Known Implementing Classes:
AbstractCorrelatingMessageHandler.SequenceAwareMessageGroup
,SimpleMessageGroup
public interface MessageGroup
A group of messages that are correlated with each other and should be processed in the same context.
The message group allows implementations to be mutable, but this behavior is optional. Implementations should take care to document their thread safety and mutability.
- Author:
- Dave Syer, Oleg Zhurakousky, Gary Russell, Artem Bilan
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the message to this group.boolean
Query if the message can be added.void
clear()
void
complete()
Complete the group.Return the condition for this group to consult with, e.g.long
int
Collection<Message<?>>
Return all available Messages from the group at the time of invocation.Message<?>
getOne()
int
long
boolean
boolean
Remove the message from this group.void
setCondition
(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()
Return a stream for messages stored in this group.
-
Method Details
-
canAdd
Query if the message can be added.- Parameters:
message
- The message.- Returns:
- true if the message can be added.
-
add
Add the message to this group.- Parameters:
messageToAdd
- the message to add.- Since:
- 4.3
-
remove
Remove the message from this group.- Parameters:
messageToRemove
- the message to remove.- Returns:
true
if a message was removed.- Since:
- 4.3
-
getMessages
Collection<Message<?>> getMessages()Return all available Messages from the group at the time of invocation.- Returns:
- The messages.
-
streamMessages
Return a stream for messages stored in this group.- Returns:
- the
Stream
for messages in this group. - Since:
- 5.5
-
getGroupId
Object getGroupId()- Returns:
- the key that links these messages together
-
getLastReleasedMessageSequenceNumber
int getLastReleasedMessageSequenceNumber()- Returns:
- the sequenceNumber of the last released message. Used in Resequencer use cases only
-
setLastReleasedMessageSequenceNumber
void setLastReleasedMessageSequenceNumber(int sequenceNumber) -
isComplete
boolean isComplete()- Returns:
- true if the group is complete (i.e. no more messages are expected to be added)
-
complete
void complete()Complete the group. -
getSequenceSize
int getSequenceSize()- Returns:
- the size of the sequence expected 0 if unknown
-
size
int size()- Returns:
- the total number of messages in this group
-
getOne
Message<?> getOne()- Returns:
- a single message from the group
-
getTimestamp
long getTimestamp()- Returns:
- the timestamp (milliseconds since epoch) associated with the creation of this group
-
getLastModified
long getLastModified()- Returns:
- the timestamp (milliseconds since epoch) associated with the time this group was last updated
-
setLastModified
void setLastModified(long lastModified) -
setCondition
Add a condition statement to this group which can be consulted later on, e.g. from the release strategy.- Parameters:
condition
- statement which could be consulted later on, e.g. from the release strategy.- Since:
- 5.5
-
getCondition
Return the condition for this group to consult with, e.g. from the release strategy.- Returns:
- the condition for this group to consult with, e.g. from the release strategy.
- Since:
- 5.5
-
clear
void clear()
-