Interface DuplicateCommandHandlerResolver
- All Known Implementing Classes:
FailingDuplicateCommandHandlerResolver,LoggingDuplicateCommandHandlerResolver
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface towards resolving the occurrence of a duplicate command handler being subscribed. As such it
ingests two
MessageHandler instances and returns another one as the resolution.- Since:
- 4.2
- Author:
- Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptionMessageHandler<? super CommandMessage<?>> resolve(String commandName, MessageHandler<? super CommandMessage<?>> registeredHandler, MessageHandler<? super CommandMessage<?>> candidateHandler) Chooses what to do when a duplicate handler is registered, returning the handler that should be selected for command handling, or otherwise throwing an exception to reject registration altogether.
-
Method Details
-
resolve
MessageHandler<? super CommandMessage<?>> resolve(@Nonnull String commandName, @Nonnull MessageHandler<? super CommandMessage<?>> registeredHandler, @Nonnull MessageHandler<? super CommandMessage<?>> candidateHandler) Chooses what to do when a duplicate handler is registered, returning the handler that should be selected for command handling, or otherwise throwing an exception to reject registration altogether.- Parameters:
commandName- The name of the Command for which the duplicate was detectedregisteredHandler- theMessageHandlerpreviously registered with the Command BuscandidateHandler- theMessageHandlerthat is newly registered and conflicts with the existing registration- Returns:
- the resolved
MessageHandler. Could be theregisteredHandler, thecandidateHandleror another handler entirely - Throws:
RuntimeException- when registration should fail
-