Class QueryConverter
java.lang.Object
org.axonframework.axonserver.connector.query.QueryConverter
Utility class to convert queries during
dispatching and handling of
subscribed query
handlers in the AxonServerQueryBusConnector.
This utility class is marked as Internal as it is specific for the AxonServerQueryBusConnector.
- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.axoniq.axonserver.grpc.query.QueryRequestconvertQueryMessage(QueryMessage query, String clientId, String componentName) Converts aQueryMessageinto aQueryRequest.static QueryMessageconvertQueryRequest(io.axoniq.axonserver.grpc.query.QueryRequest queryRequest) Converts aQueryRequestinto aQueryMessage.static QueryResponseMessageconvertQueryResponse(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse) Converts aQueryResponseinto aQueryResponseMessage.static io.axoniq.axonserver.grpc.query.QueryResponseconvertQueryResponseMessage(String requestId, QueryResponseMessage queryResponseMessage) Converts aQueryResponseMessageinto aQueryResponse.convertQueryUpdate(io.axoniq.axonserver.grpc.query.QueryUpdate queryUpdate) Converts aQueryUpdateobject into aSubscriptionQueryUpdateMessage.static io.axoniq.axonserver.grpc.query.QueryUpdateconvertQueryUpdate(String clientId, ErrorCode errorCode, Throwable error) Converts error information and a client identifier into aQueryUpdate.static io.axoniq.axonserver.grpc.query.QueryUpdateConverts aSubscriptionQueryUpdateMessageinto aQueryUpdate.static QueryMessageconvertSubscriptionQueryMessage(io.axoniq.axonserver.grpc.query.SubscriptionQuery query) Converts aSubscriptionQueryinto aQueryMessage.
-
Method Details
-
convertQueryRequest
@Nonnull public static QueryMessage convertQueryRequest(@Nonnull io.axoniq.axonserver.grpc.query.QueryRequest queryRequest) Converts aQueryRequestinto aQueryMessage. This method processes the given QueryRequest by extracting its payload, metadata, and other relevant fields to construct a QueryMessage that represents the request for querying information.- Parameters:
queryRequest- TheQueryRequestto be converted into aQueryMessage. Must not be null.- Returns:
- A
QueryMessagerepresentation of the providedQueryRequest. The returned object contains the extracted payload, metadata, and expected response type. - Throws:
NullPointerException- if the providedQueryRequestis null.
-
convertQueryMessage
public static io.axoniq.axonserver.grpc.query.QueryRequest convertQueryMessage(@Nonnull QueryMessage query, @Nonnull String clientId, @Nonnull String componentName) Converts aQueryMessageinto aQueryRequest. This method processes the providedQueryMessageand constructs a correspondingQueryRequestwith all necessary details, such as metadata, payload, and other processing instructions.- Parameters:
query- TheQueryMessageto be converted. Must not be null. The payload must be of typebyte[], otherwise anIllegalArgumentExceptionis thrown.clientId- The identifier of the client making the query. Must not be null.componentName- The name of the component handling the query. Must not be null.- Returns:
- a
QueryRequestThat represents the providedQueryMessage. Contains the extracted metadata, payload, and other specific configurations from the original message. - Throws:
IllegalArgumentException- if the payload of theQueryMessageis not of typebyte[].
-
convertQueryResponse
public static QueryResponseMessage convertQueryResponse(@Nonnull io.axoniq.axonserver.grpc.query.QueryResponse queryResponse) Converts aQueryResponseinto aQueryResponseMessage. This method processes the givenQueryResponse, extracts its payload, metadata, and other necessary components to construct a correspondingQueryResponseMessage. If theQueryResponsecontains an error, an appropriate exception is included in the resultingQueryResponseMessage.- Parameters:
queryResponse- TheQueryResponseto be converted. Must not be null. TheQueryResponseshould contain valid payload and metadata details necessary to construct the resultingQueryResponseMessage.- Returns:
- A
QueryResponseMessagerepresentation of the providedQueryResponse. The returned message includes the processed payload, metadata, and any error information, if applicable. - Throws:
IllegalArgumentException- if the providedQueryResponsecontains an error, in which case we useExceptionConverter.convertToAxonException(String, ErrorMessage, SerializedObject).
-
convertQueryResponseMessage
public static io.axoniq.axonserver.grpc.query.QueryResponse convertQueryResponseMessage(@Nonnull String requestId, @Nonnull QueryResponseMessage queryResponseMessage) Converts aQueryResponseMessageinto aQueryResponse.This method processes the provided
QueryResponseMessageto construct a correspondingQueryResponse. The resultingQueryResponsecontains the message identifier, request identifier, processed payload, metadata, and other necessary information.- Parameters:
requestId- TheMessage.identifier()that initiated the query. Used to associate the resultingQueryResponsewith the original request. Must not be null.queryResponseMessage- TheQueryResponseMessageto be converted into aQueryResponse. Must not be null.- Returns:
- A
QueryResponserepresentation of the providedQueryResponseMessage. It includes the identifier, metadata, and the serialized payload.
-
convertSubscriptionQueryMessage
public static QueryMessage convertSubscriptionQueryMessage(@Nonnull io.axoniq.axonserver.grpc.query.SubscriptionQuery query) Converts aSubscriptionQueryinto aQueryMessage. This method processes the givenSubscriptionQueryby extracting its identifier, payload, metadata, and other necessary fields to construct aQueryMessage.- Parameters:
query- TheSubscriptionQueryto be converted. Must not be null. TheSubscriptionQueryshould contain properly set payload, metadata, and response type details.- Returns:
- A
QueryMessagerepresentation of the providedSubscriptionQuery. It includes the processed payload, metadata, and response type. - Throws:
NullPointerException- if the providedSubscriptionQueryis null.
-
convertQueryUpdate
public static io.axoniq.axonserver.grpc.query.QueryUpdate convertQueryUpdate(@Nonnull SubscriptionQueryUpdateMessage update) Converts aSubscriptionQueryUpdateMessageinto aQueryUpdate. This method processes the providedSubscriptionQueryUpdateMessageby extracting its payload, metadata, and other relevant details to construct aQueryUpdate. If the payload is unavailable, it defaults to an empty byte array.- Parameters:
update- TheSubscriptionQueryUpdateMessageto be converted. Must not be null. The payload and metadata should be properly set in the provided update.- Returns:
- A
QueryUpdaterepresentation of the givenSubscriptionQueryUpdateMessage. It includes the extracted payload, metadata, and other necessary information. - Throws:
NullPointerException- if the providedSubscriptionQueryUpdateMessageis null.
-
convertQueryUpdate
public static SubscriptionQueryUpdateMessage convertQueryUpdate(@Nonnull io.axoniq.axonserver.grpc.query.QueryUpdate queryUpdate) Converts aQueryUpdateobject into aSubscriptionQueryUpdateMessage.- Parameters:
queryUpdate- TheQueryUpdateobject to be converted; must not be null.- Returns:
- A
SubscriptionQueryUpdateMessagecreated from the providedQueryUpdate.
-
convertQueryUpdate
public static io.axoniq.axonserver.grpc.query.QueryUpdate convertQueryUpdate(String clientId, @Nullable ErrorCode errorCode, Throwable error) Converts error information and a client identifier into aQueryUpdate. This method creates aQueryUpdatecontaining the error message derived from the givenThrowablealong with the provided client identifier.- Parameters:
clientId- The identifier of the client associated with the error. Must not be null.errorCode- The error code identifying the type of action that resulted in an error, if known.error- TheThrowablecontaining error details to be translated into an error message. Must not be null.- Returns:
- A
QueryUpdatecontaining the client identifier and an error message derived from the providedThrowable.
-