Class CommandSequencingInterceptor<M extends CommandMessage>
java.lang.Object
org.axonframework.messaging.commandhandling.interception.CommandSequencingInterceptor<M>
- Type Parameters:
M- the Message type this interceptor can process
- All Implemented Interfaces:
MessageHandlerInterceptor<M>
public class CommandSequencingInterceptor<M extends CommandMessage>
extends Object
implements MessageHandlerInterceptor<M>
A
MessageHandlerInterceptor implementation to sequence command execution.
Commands are sequenced based on a SequencingPolicy that specifies how to determine the sequence identifier
from the CommandMessage that is being intercepted. Commands with the same sequence identifier will be
executed sequentially, meaning that a command will wait for the previous command with the same identifier to complete
before starting execution. Commands with different sequence identifiers can be executed concurrently.
Commands for which the policy returns Optional.empty() as sequence identifier will proceed without any
sequencing constraints.
- Since:
- 5.0.3
- Author:
- Jakob Hatzl
-
Constructor Summary
ConstructorsConstructorDescriptionCommandSequencingInterceptor(SequencingPolicy<? super CommandMessage> sequencingPolicy) Construct aCommandSequencingInterceptorthat sequences command execution based on the suppliedSequencingPolicy. -
Method Summary
Modifier and TypeMethodDescriptioninterceptOnHandle(M message, ProcessingContext context, MessageHandlerInterceptorChain<M> interceptorChain) Intercepts a givenmessageon handling before reaching the designatedMessageHandler.
-
Constructor Details
-
CommandSequencingInterceptor
Construct aCommandSequencingInterceptorthat sequences command execution based on the suppliedSequencingPolicy.- Parameters:
sequencingPolicy- theSequencingPolicyto apply for retrieving the sequence identifier from theCommandMessage.
-
-
Method Details
-
interceptOnHandle
public MessageStream<?> interceptOnHandle(M message, ProcessingContext context, 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 CommandMessage>- 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).
-