Class CommandSerializer

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

public class CommandSerializer extends Object
Converter between Axon Framework CommandMessages and Axon Server gRPC Command messages.
Since:
4.0
Author:
Marc Gathier
  • Constructor Summary

    Constructors
    Constructor
    Description
    CommandSerializer(org.axonframework.serialization.Serializer serializer, AxonServerConfiguration configuration)
    Instantiate a serializer used to convert Axon CommandMessages and CommandResultMessages into Axon Server gRPC messages and vice versa.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.axonframework.commandhandling.CommandMessage<?>
    deserialize(io.axoniq.axonserver.grpc.command.Command command)
    Convert a Command into a CommandMessage.
    <R> org.axonframework.commandhandling.CommandResultMessage<R>
    deserialize(io.axoniq.axonserver.grpc.command.CommandResponse commandResponse)
    Convert a CommandResponse into a CommandResultMessage.
    io.axoniq.axonserver.grpc.command.Command
    serialize(org.axonframework.commandhandling.CommandMessage<?> commandMessage, String routingKey, int priority)
    Convert a CommandMessage into a Command.
    io.axoniq.axonserver.grpc.command.CommandResponse
    serialize(org.axonframework.commandhandling.CommandResultMessage<?> commandResultMessage, String requestIdentifier)
    Convert a CommandResultMessage into a CommandProviderOutbound.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CommandSerializer

      public CommandSerializer(org.axonframework.serialization.Serializer serializer, AxonServerConfiguration configuration)
      Instantiate a serializer used to convert Axon CommandMessages and CommandResultMessages into Axon Server gRPC messages and vice versa. The provided serializer is used for both from and to framework-server conversions.
      Parameters:
      serializer - a Serializer used to de-/serialize an Axon Server gRPC message into a CommandMessage or CommandResultMessage and vice versa
      configuration - an AxonServerConfiguration used to set the configurable component id and name in the messages
  • Method Details

    • serialize

      public io.axoniq.axonserver.grpc.command.Command serialize(org.axonframework.commandhandling.CommandMessage<?> commandMessage, String routingKey, int priority)
      Convert a CommandMessage into a Command. The routingKey and priority respectively define which service to route the command to and what the command's priority among others is.
      Parameters:
      commandMessage - the CommandMessage to convert into a Command
      routingKey - a String defining the routing key of the given CommandMessage
      priority - a int defining the priority of the given CommandMessage
      Returns:
      a Command based on the provided commandMessage
    • serialize

      public io.axoniq.axonserver.grpc.command.CommandResponse serialize(org.axonframework.commandhandling.CommandResultMessage<?> commandResultMessage, String requestIdentifier)
      Convert a CommandResultMessage into a CommandProviderOutbound.
      Parameters:
      commandResultMessage - the CommandResultMessage to convert into a CommandProviderOutbound
      requestIdentifier - a String identifying where the original request came from
      Returns:
      a CommandProviderOutbound based on the provided commandResultMessage
    • deserialize

      public org.axonframework.commandhandling.CommandMessage<?> deserialize(io.axoniq.axonserver.grpc.command.Command command)
      Convert a Command into a CommandMessage.
      Parameters:
      command - the Command to convert into a CommandMessage
      Returns:
      a CommandMessage based on the provided command
    • deserialize

      public <R> org.axonframework.commandhandling.CommandResultMessage<R> deserialize(io.axoniq.axonserver.grpc.command.CommandResponse commandResponse)
      Convert a CommandResponse into a CommandResultMessage.
      Type Parameters:
      R - a generic specifying the response payload type
      Parameters:
      commandResponse - the CommandResponse to convert into a CommandResultMessage
      Returns:
      a CommandResultMessage of generic R based on the provided commandResponse