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 QueryResponseMessageconvertQueryResponse(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse, @Nullable Converter converter) 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, @Nullable Converter converter) Converts aQueryUpdateobject into aSubscriptionQueryUpdateMessage.static io.axoniq.axonserver.grpc.query.QueryUpdateconvertQueryUpdate(String clientId, @Nullable 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, @Nullable Converter converter) Converts aSubscriptionQueryinto aQueryMessage.
-
Method Details
-
convertQueryMessage
public static io.axoniq.axonserver.grpc.query.QueryRequest convertQueryMessage(QueryMessage query, String clientId, 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(io.axoniq.axonserver.grpc.query.QueryResponse queryResponse, @Nullable Converter converter) 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.converter- the converter to be used for payload conversion- 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(String requestId, 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(io.axoniq.axonserver.grpc.query.SubscriptionQuery query, @Nullable Converter converter) 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 detailsconverter- the converter to be used for payload conversion- 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(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(io.axoniq.axonserver.grpc.query.QueryUpdate queryUpdate, @Nullable Converter converter) Converts aQueryUpdateobject into aSubscriptionQueryUpdateMessage.- Parameters:
queryUpdate- TheQueryUpdateobject to be converted; must not be null.converter- the converter to be used for payload conversion- 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.
-