Class GrpcBackedCommandMessage<C>

java.lang.Object
org.axonframework.axonserver.connector.command.GrpcBackedCommandMessage<C>
Type Parameters:
C - a generic specifying the payload type of the wrapped CommandMessage
All Implemented Interfaces:
Serializable, CommandMessage<C>, Message<C>

public class GrpcBackedCommandMessage<C> extends Object implements CommandMessage<C>
Wrapper that allows clients to access a gRPC Command as a CommandMessage.
Since:
4.0
Author:
Marc Gathier
See Also:
  • Constructor Details

    • GrpcBackedCommandMessage

      public GrpcBackedCommandMessage(io.axoniq.axonserver.grpc.command.Command command, Serializer serializer)
      Instantiate a GrpcBackedCommandMessage with the given command and using the provided Serializer to be able to retrieve the payload and MetaData from it.
      Parameters:
      command - the Command which is being wrapped as a CommandMessage
      serializer - the Serializer used to deserialize the payload and MetaData from the given command
  • Method Details

    • getCommandName

      public String getCommandName()
      Description copied from interface: CommandMessage
      Returns the name of the command to execute. This is an indication of what should be done, using the payload as parameter.
      Specified by:
      getCommandName in interface CommandMessage<C>
      Returns:
      the name of the command
    • getIdentifier

      public String getIdentifier()
      Description copied from interface: Message
      Returns the identifier of this message. Two messages with the same identifiers should be interpreted as different representations of the same conceptual message. In such case, the meta-data may be different for both representations. The payload may be identical.
      Specified by:
      getIdentifier in interface Message<C>
      Returns:
      the unique identifier of this message
    • getMetaData

      public MetaData getMetaData()
      Description copied from interface: Message
      Returns the meta data for this message. This meta data is a collection of key-value pairs, where the key is a String, and the value is a serializable object.
      Specified by:
      getMetaData in interface Message<C>
      Returns:
      the meta data for this message
    • getPayload

      public C getPayload()
      Description copied from interface: Message
      Returns the payload of this message. The payload is the application-specific information.
      Specified by:
      getPayload in interface Message<C>
      Returns:
      the payload of this message
    • getPayloadType

      public Class<C> getPayloadType()
      Description copied from interface: Message
      Returns the type of the payload.

      Is semantically equal to getPayload().getClass(), but allows implementations to optimize by using lazy loading or deserialization.

      Specified by:
      getPayloadType in interface Message<C>
      Returns:
      the type of payload.
    • withMetaData

      public GrpcBackedCommandMessage<C> withMetaData(@Nonnull Map<String,?> metaData)
      Description copied from interface: CommandMessage
      Returns a copy of this CommandMessage with the given metaData. The payload remains unchanged.

      While the implementation returned may be different than the implementation of this, implementations must take special care in returning the same type of Message (e.g. EventMessage, DomainEventMessage) to prevent errors further downstream.

      Specified by:
      withMetaData in interface CommandMessage<C>
      Specified by:
      withMetaData in interface Message<C>
      Parameters:
      metaData - The new MetaData for the Message
      Returns:
      a copy of this message with the given MetaData
    • andMetaData

      public GrpcBackedCommandMessage<C> andMetaData(@Nonnull Map<String,?> metaData)
      Description copied from interface: CommandMessage
      Returns a copy of this CommandMessage with it MetaData merged with the given metaData. The payload remains unchanged.
      Specified by:
      andMetaData in interface CommandMessage<C>
      Specified by:
      andMetaData in interface Message<C>
      Parameters:
      metaData - The MetaData to merge with
      Returns:
      a copy of this message with the given MetaData