Class FailingDuplicateCommandHandlerResolver

java.lang.Object
org.axonframework.commandhandling.FailingDuplicateCommandHandlerResolver
All Implemented Interfaces:
DuplicateCommandHandlerResolver

public class FailingDuplicateCommandHandlerResolver extends Object implements DuplicateCommandHandlerResolver
Implementation of DuplicateCommandHandlerResolver that throws a DuplicateCommandHandlerSubscriptionException when a duplicate registration is detected.
Since:
4.2
Author:
Allard Buijze
  • Method Details

    • instance

      public static FailingDuplicateCommandHandlerResolver instance()
      Returns a DuplicateCommandHandlerResolver that throws an exception when a duplicate registration is detected
      Returns:
      a DuplicateCommandHandlerResolver that throws an exception when a duplicate registration is detected
    • resolve

      public MessageHandler<? super CommandMessage<?>> resolve(@Nonnull String commandName, @Nonnull MessageHandler<? super CommandMessage<?>> registeredHandler, @Nonnull MessageHandler<? super CommandMessage<?>> candidateHandler)
      Description copied from interface: DuplicateCommandHandlerResolver
      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.
      Specified by:
      resolve in interface DuplicateCommandHandlerResolver
      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