Class LoggingInterceptor<M extends Message>
java.lang.Object
org.axonframework.messaging.core.interception.LoggingInterceptor<M>
- Type Parameters:
M- The message type this interceptor can process.
- All Implemented Interfaces:
MessageDispatchInterceptor<M>,MessageHandlerInterceptor<M>
public class LoggingInterceptor<M extends Message>
extends Object
implements MessageDispatchInterceptor<M>, MessageHandlerInterceptor<M>
A
MessageDispatchInterceptor and MessageHandlerInterceptor implementation that logs dispatched and
incoming messages, and their result, to a Logger.
Allows configuration of the name under which the logger should log the statements.
Dispatched, incoming messages and successful executions are logged at theINFO level. Processing errors are
logged using the WARN level.- Since:
- 0.6.0
- Author:
- Allard Buijze
-
Constructor Summary
ConstructorsConstructorDescriptionInitialize theLoggingInterceptorwith the default logger name, which is the fully qualified class name of this logger.LoggingInterceptor(String loggerName) Initialize theLoggingInterceptorwith the givenloggerName. -
Method Summary
Modifier and TypeMethodDescriptioninterceptOnDispatch(M message, ProcessingContext context, MessageDispatchInterceptorChain<M> interceptorChain) Intercepts a givenmessageon dispatching.interceptOnHandle(M message, ProcessingContext context, MessageHandlerInterceptorChain<M> interceptorChain) Intercepts a givenmessageon handling before reaching the designatedMessageHandler.
-
Constructor Details
-
LoggingInterceptor
Initialize theLoggingInterceptorwith the givenloggerName.The actual logging implementation will use this name to decide the appropriate log level and location. See the documentation of your logging implementation for more information.
- Parameters:
loggerName- The name of the logger.
-
LoggingInterceptor
public LoggingInterceptor()Initialize theLoggingInterceptorwith the default logger name, which is the fully qualified class name of this logger.- See Also:
-
-
Method Details
-
interceptOnDispatch
@Nonnull public MessageStream<?> interceptOnDispatch(@Nonnull M message, @Nullable ProcessingContext context, @Nonnull MessageDispatchInterceptorChain<M> interceptorChain) Description copied from interface:MessageDispatchInterceptorIntercepts a givenmessageon dispatching. The implementer of this method might want to intercept the message before passing it to the chain (effectively before callingMessageDispatchInterceptorChain.proceed(Message, ProcessingContext)) or after the chain (by mapping the resulting message by callingMessageStream.mapMessage(Function)).- Specified by:
interceptOnDispatchin interfaceMessageDispatchInterceptor<M extends Message>- Parameters:
message- The message to intercept on dispatching.context- The active processing context, if any. Can be used to (e.g.) validate correlation data.interceptorChain- The interceptor chain to signal that processing is finished and further interceptors should be called.- Returns:
- The resulting message stream from
MessageDispatchInterceptorChain.proceed(Message, ProcessingContext).
-
interceptOnHandle
@Nonnull public MessageStream<?> interceptOnHandle(@Nonnull M message, @Nonnull ProcessingContext context, @Nonnull MessageHandlerInterceptorChain<M> interceptorChain) Description copied from interface:MessageHandlerInterceptorIntercepts a givenmessageon handling before reaching the designatedMessageHandler. The interceptor is responsible for the continuation of the handling process by invoking theMessageHandlerInterceptorChain.proceed(Message, ProcessingContext)method on the giveninterceptorChain. The givencontextcontains contextual information. Any information gathered by interceptors may be attached to the context. Interceptors are not allowed to change the type of the message handling result, as the dispatching component expects a result of a specific type.- Specified by:
interceptOnHandlein interfaceMessageHandlerInterceptor<M extends Message>- Parameters:
message- The message to intercept on handling.context- The active processing context of themessagebeing processed.interceptorChain- The interceptor chain that allows this interceptor to proceed the dispatch process.- Returns:
- The resulting message stream from
MessageHandlerInterceptorChain.proceed(Message, ProcessingContext).
-