Class GrpcBackedResponseMessage<R>

java.lang.Object
org.axonframework.axonserver.connector.query.GrpcBackedResponseMessage<R>
Type Parameters:
R - a generic specifying the type of the QueryResponseMessage
All Implemented Interfaces:
Serializable, Message<R>, ResultMessage<R>, QueryResponseMessage<R>

public class GrpcBackedResponseMessage<R> extends Object implements QueryResponseMessage<R>
Wrapper that allows clients to access a gRPC QueryResponse as a QueryResponseMessage.
Since:
4.0
Author:
Marc Gathier
See Also:
  • Constructor Details

    • GrpcBackedResponseMessage

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

    • 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<R>
      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<R>
      Returns:
      the meta data for this message
    • getPayload

      public R 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<R>
      Returns:
      the payload of this message
    • getPayloadType

      public Class<R> 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<R>
      Returns:
      the type of payload.
    • isExceptional

      public boolean isExceptional()
      Description copied from interface: ResultMessage
      Indicates whether the ResultMessage represents unsuccessful execution.
      Specified by:
      isExceptional in interface ResultMessage<R>
      Returns:
      true if execution was unsuccessful, false otherwise
    • optionalExceptionResult

      public Optional<Throwable> optionalExceptionResult()
      Description copied from interface: ResultMessage
      Returns the Exception in case of exceptional result message or an empty Optional in case of successful execution.
      Specified by:
      optionalExceptionResult in interface ResultMessage<R>
      Returns:
      an Optional containing exception result or an empty Optional in case of a successful execution
    • withMetaData

      public GrpcBackedResponseMessage<R> withMetaData(@Nonnull Map<String,?> metaData)
      Description copied from interface: QueryResponseMessage
      Returns a copy of this QueryResponseMessage with the given metaData. The payload remains unchanged.
      Specified by:
      withMetaData in interface Message<R>
      Specified by:
      withMetaData in interface QueryResponseMessage<R>
      Specified by:
      withMetaData in interface ResultMessage<R>
      Parameters:
      metaData - The new MetaData for the QueryResponseMessage
      Returns:
      a copy of this message with the given MetaData
    • andMetaData

      public GrpcBackedResponseMessage<R> andMetaData(@Nonnull Map<String,?> metaData)
      Description copied from interface: QueryResponseMessage
      Returns a copy of this QueryResponseMessage with its MetaData merged with given metaData. The payload remains unchanged.
      Specified by:
      andMetaData in interface Message<R>
      Specified by:
      andMetaData in interface QueryResponseMessage<R>
      Specified by:
      andMetaData in interface ResultMessage<R>
      Parameters:
      metaData - The MetaData to merge into the QueryResponseMessage
      Returns:
      a copy of this message with the given additional MetaData