Class QuerySerializer

java.lang.Object
org.axonframework.axonserver.connector.query.QuerySerializer

public class QuerySerializer extends Object
Converter between Axon Framework QueryMessage and QueryResponseMessage and Axon Server gRPC Query and QueryResponse messages.
Since:
4.0
Author:
Marc Gathier
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    <Q, R> org.axonframework.queryhandling.QueryMessage<Q,R>
    deserializeRequest(io.axoniq.axonserver.grpc.query.QueryRequest queryRequest)
    Convert a QueryRequest into a QueryMessage.
    org.axonframework.queryhandling.QueryResponseMessage<?>
    deserializeResponse(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse)
    Converts a QueryResponse into a QueryResponseMessage.
    <R> org.axonframework.queryhandling.QueryResponseMessage<R>
    deserializeResponse(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse, org.axonframework.messaging.responsetypes.ResponseType<R> expectedResponseType)
    Convert a QueryResponse into a QueryResponseMessage.
    <Q, R> io.axoniq.axonserver.grpc.query.QueryRequest
    serializeRequest(org.axonframework.queryhandling.QueryMessage<Q,R> queryMessage, int nrResults, long timeout, int priority)
    Convert a QueryMessage into a QueryRequest.
    <Q, R> io.axoniq.axonserver.grpc.query.QueryRequest
    serializeRequest(org.axonframework.queryhandling.QueryMessage<Q,R> queryMessage, int nrResults, long timeout, int priority, boolean stream)
    Convert a QueryMessage into a QueryRequest.
    io.axoniq.axonserver.grpc.query.QueryResponse
    serializeResponse(org.axonframework.queryhandling.QueryResponseMessage<?> queryResponse, String requestMessageId)
    Convert a QueryResponseMessage into a QueryResponse.

    Methods inherited from class java.lang.Object

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

    • QuerySerializer

      public QuerySerializer(org.axonframework.serialization.Serializer messageSerializer, org.axonframework.serialization.Serializer serializer, AxonServerConfiguration configuration)
      Instantiate a serializer used to convert Axon QueryMessages and QueryResponseMessages into Axon Server gRPC messages and vice versa. The provided messageSerializer is used for converting a message's payload and metadata, whilst the serializer is used to convert a QueryMessage's ResponseType.
      Parameters:
      messageSerializer - a Serializer used to de-/serialize an Axon Server gRPC message into QueryMessages and QueryResponseMessages and vice versa
      serializer - a Serializer used to create a dedicated converter for a QueryMessage ResponseType
      configuration - an AxonServerConfiguration used to set the configurable component id and name in the messages
  • Method Details

    • serializeRequest

      public <Q, R> io.axoniq.axonserver.grpc.query.QueryRequest serializeRequest(org.axonframework.queryhandling.QueryMessage<Q,R> queryMessage, int nrResults, long timeout, int priority)
      Convert a QueryMessage into a QueryRequest. The provided nrResults, timeout and priority are all set on the QueryRequest to respectively define the number of results, after which time the query should be aborted and the priority of the query amont others.
      Type Parameters:
      Q - a generic specifying the payload type of the given queryMessage
      R - a generic specifying the response type of the given queryMessage
      Parameters:
      queryMessage - the QueryMessage to convert into a QueryRequest
      nrResults - an int denoting the number of expected results
      timeout - a long specifying the timeout in milliseconds of the created QueryRequest
      priority - a int defining the priority among other QueryRequests
      Returns:
      a QueryRequest based on the provided queryMessage
    • serializeRequest

      public <Q, R> io.axoniq.axonserver.grpc.query.QueryRequest serializeRequest(org.axonframework.queryhandling.QueryMessage<Q,R> queryMessage, int nrResults, long timeout, int priority, boolean stream)
      Convert a QueryMessage into a QueryRequest. The provided nrResults, timeout and priority are all set on the QueryRequest to respectively define the number of results, after which time the query should be aborted and the priority of the query amont others.
      Type Parameters:
      Q - a generic specifying the payload type of the given queryMessage
      R - a generic specifying the response type of the given queryMessage
      Parameters:
      queryMessage - the QueryMessage to convert into a QueryRequest
      nrResults - an int denoting the number of expected results
      timeout - a long specifying the timeout in milliseconds of the created QueryRequest
      priority - a int defining the priority among other QueryRequests
      stream - indicates whether results of this query should be streamed or not
      Returns:
      a QueryRequest based on the provided queryMessage
    • serializeResponse

      public io.axoniq.axonserver.grpc.query.QueryResponse serializeResponse(org.axonframework.queryhandling.QueryResponseMessage<?> queryResponse, String requestMessageId)
      Convert a QueryResponseMessage into a QueryResponse.
      Parameters:
      queryResponse - a QueryResponseMessage to convert into a QueryResponse
      requestMessageId - a String specifying the identity of the original request message
      Returns:
      a QueryResponse based on the provided queryResponse
    • deserializeRequest

      public <Q, R> org.axonframework.queryhandling.QueryMessage<Q,R> deserializeRequest(io.axoniq.axonserver.grpc.query.QueryRequest queryRequest)
      Convert a QueryRequest into a QueryMessage.
      Type Parameters:
      Q - a generic specifying the payload type of the QueryMessage to convert to
      R - a generic specifying the response type of the QueryMessage to convert to
      Parameters:
      queryRequest - a QueryRequest to convert into a QueryMessage
      Returns:
      a QueryMessage based on the provided queryRequest
    • deserializeResponse

      public <R> org.axonframework.queryhandling.QueryResponseMessage<R> deserializeResponse(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse, org.axonframework.messaging.responsetypes.ResponseType<R> expectedResponseType)
      Convert a QueryResponse into a QueryResponseMessage.
      Type Parameters:
      R - a generic specifying the type of the QueryResponseMessage to convert to
      Parameters:
      queryResponse - a QueryResponse to convert into a QueryResponseMessage
      Returns:
      a QueryResponseMessage based on the provided queryResponse
    • deserializeResponse

      public org.axonframework.queryhandling.QueryResponseMessage<?> deserializeResponse(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse)
      Converts a QueryResponse into a QueryResponseMessage. It does not assume the type of the payload.
      Parameters:
      queryResponse - a QueryResponse to convert into a QueryResponseMessage
      Returns:
      a QueryResponseMessage based on the provided queryResponse