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, @Nullable Converter converter) static io.axoniq.axonserver.grpc.command.CommandconvertCommandMessage(CommandMessage command, String clientId, String componentName) convertCommandResponse(io.axoniq.axonserver.grpc.command.CommandResponse commandResponse, @Nullable Converter converter) Converts the givencommandResponseto aCommandResultMessage, wrapped in aCompletableFuturefor convenience when dealing withCommandResponsesduringdispatching.static io.axoniq.axonserver.grpc.command.CommandResponseconvertResultMessage(@Nullable 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(CommandMessage command, String clientId, 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(io.axoniq.axonserver.grpc.command.CommandResponse commandResponse, @Nullable Converter converter) Converts the givencommandResponseto aCommandResultMessage, wrapped in aCompletableFuturefor convenience when dealing withCommandResponsesduringdispatching.- Parameters:
commandResponse- the command response to convert to aCommandResultMessageconverter- the converter to use for payload conversion in the resultingCommandResultMessage- Returns:
- the
commandResponseconverted to aCommandResultMessage, wrapped in aCompletableFuturefor convenience
-
convertCommand
public static CommandMessage convertCommand(io.axoniq.axonserver.grpc.command.Command command, @Nullable Converter converter) - Parameters:
command- the command to convert to aCommandMessageconverter- the converter to use for payload conversion in the resultingCommandMessage- Returns:
- the given
commandconverted into aCommandMessage
-
convertResultMessage
public static io.axoniq.axonserver.grpc.command.CommandResponse convertResultMessage(@Nullable CommandResultMessage resultMessage, 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.
-