Class QuerySerializer
java.lang.Object
org.axonframework.axonserver.connector.query.QuerySerializer
Converter between Axon Framework
QueryMessage and QueryResponseMessage and Axon Server gRPC Query and QueryResponse messages.- Since:
- 4.0
- Author:
- Marc Gathier
-
Constructor Summary
ConstructorsConstructorDescriptionQuerySerializer(Serializer messageSerializer, Serializer serializer, AxonServerConfiguration configuration) Instantiate a serializer used to convert AxonQueryMessages andQueryResponseMessages into Axon Server gRPC messages and vice versa. -
Method Summary
Modifier and TypeMethodDescription<Q,R> QueryMessage <Q, R> deserializeRequest(io.axoniq.axonserver.grpc.query.QueryRequest queryRequest) Convert aQueryRequestinto aQueryMessage.deserializeResponse(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse) Converts aQueryResponseinto aQueryResponseMessage.<R> QueryResponseMessage<R> deserializeResponse(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse, ResponseType<R> expectedResponseType) Convert aQueryResponseinto aQueryResponseMessage.<Q,R> io.axoniq.axonserver.grpc.query.QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage, int nrResults, long timeout, int priority) Convert aQueryMessageinto aQueryRequest.<Q,R> io.axoniq.axonserver.grpc.query.QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage, int nrResults, long timeout, int priority, boolean stream) Convert aQueryMessageinto aQueryRequest.io.axoniq.axonserver.grpc.query.QueryResponseserializeResponse(QueryResponseMessage<?> queryResponse, String requestMessageId) Convert aQueryResponseMessageinto aQueryResponse.
-
Constructor Details
-
QuerySerializer
public QuerySerializer(Serializer messageSerializer, Serializer serializer, AxonServerConfiguration configuration) Instantiate a serializer used to convert AxonQueryMessages andQueryResponseMessages into Axon Server gRPC messages and vice versa. The providedmessageSerializeris used for converting a message's payload and metadata, whilst theserializeris used to convert aQueryMessage'sResponseType.- Parameters:
messageSerializer- aSerializerused to de-/serialize an Axon Server gRPC message intoQueryMessages andQueryResponseMessages and vice versaserializer- aSerializerused to create a dedicated converter for aQueryMessageResponseTypeconfiguration- anAxonServerConfigurationused to set the configurable component id and name in the messages
-
-
Method Details
-
serializeRequest
public <Q,R> io.axoniq.axonserver.grpc.query.QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage, int nrResults, long timeout, int priority) Convert aQueryMessageinto aQueryRequest. The providednrResults,timeoutandpriorityare 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 givenqueryMessageR- a generic specifying the response type of the givenqueryMessage- Parameters:
queryMessage- theQueryMessageto convert into aQueryRequestnrResults- anintdenoting the number of expected resultstimeout- alongspecifying the timeout in milliseconds of the createdQueryRequestpriority- aintdefining the priority among otherQueryRequests- Returns:
- a
QueryRequestbased on the providedqueryMessage
-
serializeRequest
public <Q,R> io.axoniq.axonserver.grpc.query.QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage, int nrResults, long timeout, int priority, boolean stream) Convert aQueryMessageinto aQueryRequest. The providednrResults,timeoutandpriorityare 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 givenqueryMessageR- a generic specifying the response type of the givenqueryMessage- Parameters:
queryMessage- theQueryMessageto convert into aQueryRequestnrResults- anintdenoting the number of expected resultstimeout- alongspecifying the timeout in milliseconds of the createdQueryRequestpriority- aintdefining the priority among otherQueryRequestsstream- indicates whether results of this query should be streamed or not- Returns:
- a
QueryRequestbased on the providedqueryMessage
-
serializeResponse
public io.axoniq.axonserver.grpc.query.QueryResponse serializeResponse(QueryResponseMessage<?> queryResponse, String requestMessageId) Convert aQueryResponseMessageinto aQueryResponse.- Parameters:
queryResponse- aQueryResponseMessageto convert into aQueryResponserequestMessageId- aStringspecifying the identity of the original request message- Returns:
- a
QueryResponsebased on the providedqueryResponse
-
deserializeRequest
public <Q,R> QueryMessage<Q,R> deserializeRequest(io.axoniq.axonserver.grpc.query.QueryRequest queryRequest) Convert aQueryRequestinto aQueryMessage.- Type Parameters:
Q- a generic specifying the payload type of theQueryMessageto convert toR- a generic specifying the response type of theQueryMessageto convert to- Parameters:
queryRequest- aQueryRequestto convert into aQueryMessage- Returns:
- a
QueryMessagebased on the providedqueryRequest
-
deserializeResponse
public <R> QueryResponseMessage<R> deserializeResponse(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse, ResponseType<R> expectedResponseType) Convert aQueryResponseinto aQueryResponseMessage.- Type Parameters:
R- a generic specifying the type of theQueryResponseMessageto convert to- Parameters:
queryResponse- aQueryResponseto convert into aQueryResponseMessage- Returns:
- a
QueryResponseMessagebased on the providedqueryResponse
-
deserializeResponse
public QueryResponseMessage<?> deserializeResponse(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse) Converts aQueryResponseinto aQueryResponseMessage. It does not assume the type of the payload.- Parameters:
queryResponse- aQueryResponseto convert into aQueryResponseMessage- Returns:
- a
QueryResponseMessagebased on the providedqueryResponse
-