Interface CommandHandlingExceptionHandler
- All Superinterfaces:
MessageHandlingExceptionHandler<CommandMessage>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface CommandHandlingExceptionHandler
extends MessageHandlingExceptionHandler<CommandMessage>
Handles exceptions thrown by a
CommandHandler within a CommandHandlingComponent.
Return MessageStream.empty() to suppress the exception. Return MessageStream.failed(Throwable) (with
the same or a different exception) to let the error propagate to the caller. Return
MessageStream.just(org.axonframework.messaging.core.Message) with a CommandResultMessage to
substitute a result in place of the error.
The return type is MessageStream.Single because command handling always produces at most one result, matching
the contract of CommandHandler.handle(CommandMessage, ProcessingContext).
Register via
CommandHandlingModule.CommandHandlerPhase.withExceptionHandler(org.axonframework.common.configuration.ComponentBuilder).
- Since:
- 5.2.0
- Author:
- Allard Buijze
-
Method Summary
Modifier and TypeMethodDescriptionhandle(CommandMessage command, ProcessingContext context, Throwable error) Called when a command handler throws an exception.
-
Method Details
-
handle
MessageStream.Single<CommandResultMessage> handle(CommandMessage command, ProcessingContext context, Throwable error) Called when a command handler throws an exception.- Specified by:
handlein interfaceMessageHandlingExceptionHandler<CommandMessage>- Parameters:
command- the command being handled when the exception occurredcontext- the active processing contexterror- the exception thrown by the command handler- Returns:
MessageStream.empty()to suppress the error,MessageStream.failed(Throwable)to propagate it, orMessageStream.just(org.axonframework.messaging.core.Message)to substitute a result
-