@ThreadSafe public final class InterceptorChain extends java.lang.Object implements MessageInterceptor
message interceptors that
can be used to build chains of interceptors.
Just like any other MessageInterceptor, the InterceptorChain is used to process
a message before it is consumed by message consumers
on the receiver-side, or before it is sent by a message sender
to the channel infrastructure.
The interceptors of the InterceptorChain will be called in order. The result of the first interceptor is propagated to the next interceptor, and so on.
If an interceptor returns null, the chain will return null without further processing of the message.
| Constructor and Description |
|---|
InterceptorChain()
Creates an empty InterceptorChain.
|
InterceptorChain(com.google.common.collect.ImmutableList<MessageInterceptor> messageInterceptors) |
| Modifier and Type | Method and Description |
|---|---|
com.google.common.collect.ImmutableList<MessageInterceptor> |
getInterceptors()
Returns the immutable list of registered
message interceptors. |
TextMessage |
intercept(TextMessage message)
Intercepts a message using all registered interceptors and returns the resulting message.
|
public InterceptorChain()
public InterceptorChain(com.google.common.collect.ImmutableList<MessageInterceptor> messageInterceptors)
public com.google.common.collect.ImmutableList<MessageInterceptor> getInterceptors()
message interceptors.@Nullable public TextMessage intercept(@Nonnull TextMessage message)
The interceptors are called in order. The result of one interceptor is propagated to the next interceptor in the chain, until the end of the chain is reached, or one interceptor has returned null.
If null is returned, the message must be dropped by the AbstractMessageEndpoint.
Every interceptor may transform the message, or may take additional actions like, for example, logging, monitoring or other things.
intercept in interface MessageInterceptormessage - the message to intercept