public class MessagePathClassifier extends Object implements IntSupplier
In systems where messages may traverse several hops, known routes can be
registered as patterns of source IDs. Each pattern is linked to a pathId
which can later be used for metrics, monitoring or routing decisions. The
longest matching pattern wins.
Implements IntSupplier so the current thread's
MessageHistory can be classified directly via getAsInt().
| Constructor and Description |
|---|
MessagePathClassifier() |
| Modifier and Type | Method and Description |
|---|---|
MessagePathClassifier |
addPathForSourcesEnding(int pathId,
int... sources)
Registers a path ID for message histories that end with the supplied
sequence of source IDs.
|
int |
getAsInt()
Returns the path ID for the current thread's
MessageHistory. |
int |
pathFor(MessageHistory messageHistory)
Determines the
pathId for the supplied history. |
String |
toString()
Returns a readable representation of the classifier state.
|
public MessagePathClassifier addPathForSourcesEnding(int pathId, int... sources)
This method enables the user to define how the classifier should categorize certain patterns of message history.
pathId - the identifier to associate with this patternsources - the sequence of source IDs that must appear at the end of
a message historyIllegalArgumentException - if the same sequence is registered with a
different pathIdpublic int getAsInt()
MessageHistory.getAsInt in interface IntSupplierpublic int pathFor(MessageHistory messageHistory)
pathId for the supplied history.
All registered patterns are checked and the longest matching suffix is selected.
messageHistory - the history to classifyIllegalStateException - if none of the patterns applyCopyright © 2026 Chronicle Software Ltd. All rights reserved.