Class PayloadConvertingCommandBusConnector

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

public class PayloadConvertingCommandBusConnector extends DelegatingCommandBusConnector
Connector implementation that converts the payload of outgoing messages into the expected format. This is generally a byte[] or another serialized form.
Since:
5.0.0
Author:
Allard Buijze
  • Constructor Details

    • PayloadConvertingCommandBusConnector

      public PayloadConvertingCommandBusConnector(@Nonnull CommandBusConnector delegate, @Nonnull MessageConverter converter, @Nonnull Class<?> targetType)
      Initialize the PayloadConvertingConnector to use given converter to convert each Message's payload into targetType before passing it to given delegate.
      Parameters:
      delegate - The delegate to pass converted messages to.
      converter - The converter to use to convert each Message's payload.
      targetType - The desired representation of forwarded Message's payload.
  • 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
      Overrides:
      dispatch in class DelegatingCommandBusConnector
      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.
    • 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
      Overrides:
      onIncomingCommand in class DelegatingCommandBusConnector
      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
      Overrides:
      describeTo in class DelegatingCommandBusConnector
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.