Class CommandConverter
java.lang.Object
org.axonframework.axonserver.connector.command.CommandConverter
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 Summary
Modifier and TypeMethodDescriptionstatic CommandMessageconvertCommand(io.axoniq.axonserver.grpc.command.Command command) static io.axoniq.axonserver.grpc.command.CommandconvertCommandMessage(CommandMessage command, String clientId, String componentName) convertCommandResponse(io.axoniq.axonserver.grpc.command.CommandResponse commandResponse) Converts the givencommandResponseto aCommandResultMessage, wrapped in aCompletableFuturefor convenience when dealing withCommandResponsesduringdispatching.static io.axoniq.axonserver.grpc.command.CommandResponseconvertResultMessage(CommandResultMessage resultMessage, String requestIdentifier) Converts the givenresultMessage, when present, into aCommandResponse, using the givenrequestIdentifierto correlate theCommandthat led to thisCommandResponse.
-
Method Details
-
convertCommandMessage
public static io.axoniq.axonserver.grpc.command.Command convertCommandMessage(@Nonnull CommandMessage command, @Nonnull String clientId, @Nonnull String componentName) Converts the givencommandinto aCommandfordispatching.Will set the
routing keyandprioritywhen present on the givencommand.- Parameters:
command- The command message to convert to aCommand.clientId- The identifier of this application, as specific in theAxonServerConfiguration.componentName- The name of this application, as specific in theAxonServerConfiguration.- Returns:
- The given
commandconverted to aCommand.
-
convertCommandResponse
public static CompletableFuture<CommandResultMessage> convertCommandResponse(@Nonnull io.axoniq.axonserver.grpc.command.CommandResponse commandResponse) Converts the givencommandResponseto aCommandResultMessage, wrapped in aCompletableFuturefor convenience when dealing withCommandResponsesduringdispatching.- Parameters:
commandResponse- The command response to convert to aCommandResultMessage.- Returns:
- The
commandResponseconverted to aCommandResultMessage, wrapped in aCompletableFuturefor convenience.
-
convertCommand
public static CommandMessage convertCommand(@Nonnull io.axoniq.axonserver.grpc.command.Command command) - Parameters:
command- The command to convert to aCommandMessage.- Returns:
- The given
commandconverted into aCommandMessage.
-
convertResultMessage
public static io.axoniq.axonserver.grpc.command.CommandResponse convertResultMessage(@Nullable CommandResultMessage resultMessage, @Nonnull String requestIdentifier) Converts the givenresultMessage, when present, into aCommandResponse, using the givenrequestIdentifierto correlate theCommandthat led to thisCommandResponse.Whenever the
resultMessageisnull, an emptyCommandResponseis constructed instead for returning a result from handling of asubscribedcommand handler.- Parameters:
resultMessage- The result message to convert to aCommandResponse, when present.requestIdentifier- The identifier correlating theCommandResponseto theCommandthat led to the response.- Returns:
- A
CommandResponsebased on the givenresultMessageandrequestIdentifier.
-