Interface CommandBusConnector

All Superinterfaces:
DescribableComponent
All Known Implementing Classes:
AxonServerCommandBusConnector, DelegatingCommandBusConnector, PayloadConvertingCommandBusConnector

public interface CommandBusConnector extends DescribableComponent
The CommandBusConnector interface defines the contract for connecting multiple CommandBus instances. It allows for the dispatching of commands across different command bus instances, whether they are local or remote.

One connector can be wrapped with another through the DelegatingCommandBusConnector, upon which more functionality can be added, such as payload conversion or conversion.

Since:
2.0.0
Author:
Allard Buijze, Mitchell Herrijgers, Steven van Beelen
  • Method Details

    • dispatch

      @Nonnull CompletableFuture<CommandResultMessage> dispatch(@Nonnull CommandMessage command, @Nullable ProcessingContext processingContext)
      Dispatches the given command to the appropriate command bus, which may be local or remote.
      Parameters:
      command - The command message to dispatch.
      processingContext - The processing context for the command.
      Returns:
      A CompletableFuture that will complete with the result of the command handling.
    • subscribe

      CompletableFuture<Void> subscribe(@Nonnull QualifiedName commandName, int loadFactor)
      Subscribes to a command with the given commandName and a loadFactor.
      Parameters:
      commandName - The QualifiedName of the command to subscribe to.
      loadFactor - The load factor for the command, which can be used to control the distribution of command handling across multiple instances. The load factor should be a positive integer.
      Returns:
      A CompletableFuture that completes successfully when this connector subscribed to the given commandName with the given loadFactor.
    • unsubscribe

      boolean unsubscribe(@Nonnull QualifiedName commandName)
      Unsubscribes from a command with the given commandName.
      Parameters:
      commandName - The QualifiedName of the command to unsubscribe from.
      Returns:
      true if the unsubscription was successful, false otherwise.
    • onIncomingCommand

      void onIncomingCommand(@Nonnull CommandBusConnector.Handler handler)
      Registers a handler that will be called when an incoming command is received. The handler should process the command and call the provided ResultCallback to indicate success or failure.
      Parameters:
      handler - A BiConsumer that takes a CommandMessage and a CommandBusConnector.ResultCallback.