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.

@FunctionalInterface public interface DuplicateCommandHandlerResolver
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 Type
    Method
    Description
    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 detected
      registeredHandler - the MessageHandler previously registered with the Command Bus
      candidateHandler - the MessageHandler that is newly registered and conflicts with the existing registration
      Returns:
      the resolved MessageHandler. Could be the registeredHandler, the candidateHandler or another handler entirely
      Throws:
      RuntimeException - when registration should fail