Class CommandConverter

java.lang.Object
org.axonframework.axonserver.connector.command.CommandConverter

@Internal public final class CommandConverter extends Object
Utility class to convert commands during dispatching and handling of subscribed command handlers in the AxonServerCommandBusConnector.

The operations convert CommandMessages and convert CommandResponses are used during dispatching. The operations convert Commands and convert result messages are used during handling.

This utility class is marked as Internal as it is specific for the AxonServerCommandBusConnector.

Since:
5.0.0
Author:
Mitchell Herrijgers, Steven van Beelen
  • Method Details

    • convertCommandMessage

      public static io.axoniq.axonserver.grpc.command.Command convertCommandMessage(@Nonnull CommandMessage command, @Nonnull String clientId, @Nonnull String componentName)
      Converts the given command into a Command for dispatching.

      Will set the routing key and priority when present on the given command.

      Parameters:
      command - The command message to convert to a Command.
      clientId - The identifier of this application, as specific in the AxonServerConfiguration.
      componentName - The name of this application, as specific in the AxonServerConfiguration.
      Returns:
      The given command converted to a Command.
    • convertCommandResponse

      public static CompletableFuture<CommandResultMessage> convertCommandResponse(@Nonnull io.axoniq.axonserver.grpc.command.CommandResponse commandResponse)
      Converts the given commandResponse to a CommandResultMessage, wrapped in a CompletableFuture for convenience when dealing with CommandResponses during dispatching.
      Parameters:
      commandResponse - The command response to convert to a CommandResultMessage.
      Returns:
      The commandResponse converted to a CommandResultMessage, wrapped in a CompletableFuture for convenience.
    • convertCommand

      public static CommandMessage convertCommand(@Nonnull io.axoniq.axonserver.grpc.command.Command command)
      Converts the given command into a CommandMessage for handling in subscribed command handlers.
      Parameters:
      command - The command to convert to a CommandMessage.
      Returns:
      The given command converted into a CommandMessage.
    • convertResultMessage

      public static io.axoniq.axonserver.grpc.command.CommandResponse convertResultMessage(@Nullable CommandResultMessage resultMessage, @Nonnull String requestIdentifier)
      Converts the given resultMessage, when present, into a CommandResponse, using the given requestIdentifier to correlate the Command that led to this CommandResponse.

      Whenever the resultMessage is null, an empty CommandResponse is constructed instead for returning a result from handling of a subscribed command handler.

      Parameters:
      resultMessage - The result message to convert to a CommandResponse, when present.
      requestIdentifier - The identifier correlating the CommandResponse to the Command that led to the response.
      Returns:
      A CommandResponse based on the given resultMessage and requestIdentifier.