public class MessageFilter extends java.lang.Object implements MessageInterceptor
MessageInterceptor that is used to filter messages using some predicate.
MessageFilter will usually be chained using a InterceptorChain.
| Modifier and Type | Method and Description |
|---|---|
Message<java.lang.String> |
intercept(Message<java.lang.String> message)
Intercept a message and return the same message, a modified version of the incoming message, or null, if
the message should be filtered out and dropped by the
MessageEndpoint |
static MessageFilter |
messageFilter(java.util.function.Predicate<Message<java.lang.String>> predicate)
Creates a
MessageFilter that is used to filter messages from message endpoints. |
public static MessageFilter messageFilter(java.util.function.Predicate<Message<java.lang.String>> predicate)
MessageFilter that is used to filter messages from message endpoints.
Messages will be dropped, if predicate.test(message) is false
predicate - the predicate used to select messages@Nullable public final Message<java.lang.String> intercept(@Nonnull Message<java.lang.String> message)
MessageEndpoint
The intercept method of a MessageFilter returns the intercepted message, if the filter predicate returns
true. Otherwise, null is returned and the message will be dropped.intercept in interface MessageInterceptormessage - the channel-layer message with payload-type beeing a String