Class DelegatingCommandBusConnector

java.lang.Object
org.axonframework.messaging.commandhandling.distributed.DelegatingCommandBusConnector
All Implemented Interfaces:
DescribableComponent, CommandBusConnector
Direct Known Subclasses:
PayloadConvertingCommandBusConnector

public abstract class DelegatingCommandBusConnector extends Object implements CommandBusConnector
A CommandBusConnector implementation that wraps another CommandBusConnector and delegates all calls to it. This can be used to add additional functionality through decoration to a CommandBusConnector without having to implement all methods again.
Since:
5.0.0
Author:
Mitchell Herrijgers
  • Field Details

  • Constructor Details

    • DelegatingCommandBusConnector

      protected DelegatingCommandBusConnector(@Nonnull CommandBusConnector delegate)
      Initialize the WrappedConnector to delegate all calls to the given delegate.
      Parameters:
      delegate - The CommandBusConnector to delegate all calls to.
  • Method Details

    • dispatch

      @Nonnull public CompletableFuture<CommandResultMessage> dispatch(@Nonnull CommandMessage command, @Nullable ProcessingContext processingContext)
      Description copied from interface: CommandBusConnector
      Dispatches the given command to the appropriate command bus, which may be local or remote.
      Specified by:
      dispatch in interface CommandBusConnector
      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

      public CompletableFuture<Void> subscribe(@Nonnull QualifiedName commandName, int loadFactor)
      Description copied from interface: CommandBusConnector
      Subscribes to a command with the given commandName and a loadFactor.
      Specified by:
      subscribe in interface CommandBusConnector
      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

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

      public void onIncomingCommand(@Nonnull CommandBusConnector.Handler handler)
      Description copied from interface: CommandBusConnector
      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.
      Specified by:
      onIncomingCommand in interface CommandBusConnector
      Parameters:
      handler - A BiConsumer that takes a CommandMessage and a CommandBusConnector.ResultCallback.
    • describeTo

      public void describeTo(@Nonnull ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.