Class CorrelationDataInterceptor<M extends Message>
java.lang.Object
org.axonframework.messaging.core.interception.CorrelationDataInterceptor<M>
- Type Parameters:
M- The message type this interceptor can process.
- All Implemented Interfaces:
MessageDispatchInterceptor<M>,MessageHandlerInterceptor<M>
@Internal
public class CorrelationDataInterceptor<M extends Message>
extends Object
implements MessageDispatchInterceptor<M>, MessageHandlerInterceptor<M>
A
.
MessageDispatchInterceptor and MessageHandlerInterceptor implementation using
CorrelationDataProviders to collect and set a collection of correlation data.
The correlation data is registered with the ProcessingContext upon
interception of a
message under Context.ResourceKey CORRELATION_DATA. On
interceptOnDispatch(Message, ProcessingContext, MessageDispatchInterceptorChain), the
ProcessingContext is checked for the existence of this resource. When present, the given Message
receive the correlation data as additional
invalid reference
org.axonframework.messaging.MetaData
Users can expect that this CorrelationDataInterceptor is always set for the user to ensure any
correlation data is present at all time.
- Since:
- 3.0.0
- Author:
- Rene de Waele, Steven van Beelen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Context.ResourceKey<Map<String, String>> Resource key the correlation data is stored in theProcessingContext. -
Constructor Summary
ConstructorsConstructorDescriptionCorrelationDataInterceptor(Collection<CorrelationDataProvider> correlationDataProviders) Construct aCorrelationDataInterceptorthat collects correlation data fromintercepted messageswith the givencorrelationDataProviders, and sets it duringdispatchingCorrelationDataInterceptor(CorrelationDataProvider... correlationDataProviders) Construct aCorrelationDataInterceptorthat collects correlation data fromintercepted messageswith the givencorrelationDataProviders, and sets it duringdispatching -
Method Summary
Modifier and TypeMethodDescriptioninterceptOnDispatch(M message, ProcessingContext context, MessageDispatchInterceptorChain<M> chain) Intercepts a givenmessageon dispatching.interceptOnHandle(M message, ProcessingContext context, MessageHandlerInterceptorChain<M> chain) Intercepts a givenmessageon handling before reaching the designatedMessageHandler.
-
Field Details
-
CORRELATION_DATA
Resource key the correlation data is stored in theProcessingContext.
-
-
Constructor Details
-
CorrelationDataInterceptor
Construct aCorrelationDataInterceptorthat collects correlation data fromintercepted messageswith the givencorrelationDataProviders, and sets it duringdispatching- Parameters:
correlationDataProviders- The correlation data providers to generate correlation data fromintercepted messages.
-
CorrelationDataInterceptor
public CorrelationDataInterceptor(@Nonnull Collection<CorrelationDataProvider> correlationDataProviders) Construct aCorrelationDataInterceptorthat collects correlation data fromintercepted messageswith the givencorrelationDataProviders, and sets it duringdispatching- Parameters:
correlationDataProviders- The correlation data providers to generate correlation data fromintercepted messages.
-
-
Method Details
-
interceptOnDispatch
@Nonnull public MessageStream<?> interceptOnDispatch(@Nonnull M message, @Nullable ProcessingContext context, @Nonnull MessageDispatchInterceptorChain<M> chain) 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.chain- 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> chain) 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.chain- The interceptor chain that allows this interceptor to proceed the dispatch process.- Returns:
- The resulting message stream from
MessageHandlerInterceptorChain.proceed(Message, ProcessingContext).
-