Class PublisherResponseType<R>
java.lang.Object
org.axonframework.messaging.responsetypes.AbstractResponseType<org.reactivestreams.Publisher<R>>
org.axonframework.messaging.responsetypes.PublisherResponseType<R>
- Type Parameters:
R- The response type which will be matched against and converted to
- All Implemented Interfaces:
Serializable,ResponseType<org.reactivestreams.Publisher<R>>
public class PublisherResponseType<R>
extends AbstractResponseType<org.reactivestreams.Publisher<R>>
A
ResponseType implementation that will match with query
handlers that return a Publisher stream of the expected response type. If matching succeeds, the
ResponseType.convert(Object) function will be called, which will cast the query handler it's response to
R.- Since:
- 4.6.0
- Author:
- Stefan Dragisic, Milan Savic
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates that the response matches with theTypewhile returning a publisher result.Fields inherited from class org.axonframework.messaging.responsetypes.AbstractResponseType
expectedResponseTypeFields inherited from interface org.axonframework.messaging.responsetypes.ResponseType
MATCH, NO_MATCH -
Constructor Summary
ConstructorsConstructorDescriptionPublisherResponseType(Class<?> expectedResponseType) Instantiate aPublisherResponseTypewith the givenexpectedResponseTypeas the type to be matched against and to which the query response should be converted to. -
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<R> ResponseType<?> Returns theResponseTypeinstance that should be used when serializing responses.booleanMatch the query handler its responseTypewith this implementation its responseTypeR.Defines the match and its priority.Returns aClassrepresenting the type of the payload to be contained in the response message.Methods inherited from class org.axonframework.messaging.responsetypes.AbstractResponseType
equals, getExpectedResponseType, hashCode, isArray, isArrayOfExpectedType, isAssignableFrom, isGenericArrayOfExpectedType, isGenericArrayType, isGenericAssignableFrom, isIterableOfExpectedType, isParameterizedType, isParameterizedTypeOfExpectedType, isPublisherOfExpectedType, isStreamOfExpectedType, isTypeVariable, isWildcardType, isWildcardTypeWithMatchingUpperBound, projectReactorOnClassPath, unwrapIfTypeFuture
-
Field Details
-
PUBLISHER_MATCH
public static final int PUBLISHER_MATCHIndicates that the response matches with theTypewhile returning a publisher result.- See Also:
-
-
Constructor Details
-
PublisherResponseType
Instantiate aPublisherResponseTypewith the givenexpectedResponseTypeas the type to be matched against and to which the query response should be converted to.- Parameters:
expectedResponseType- the response type which is expected to be matched against and returned
-
-
Method Details
-
matches
Match the query handler its responseTypewith this implementation its responseTypeR. Will return true if the expected type is assignable to the response type, taking generic types into account.- Parameters:
responseType- the responseTypeof the query handler which is matched against- Returns:
- true if the response type is assignable to the expected type, taking generic types into account
-
matchRank
Description copied from interface:ResponseTypeDefines the match and its priority. The greater the value above 0, the better the match. This is particularly useful forMultipleInstancesResponseTypeswhen there are matches on a both multiple and single instance types. Lists should be given priority for handling.- Parameters:
responseType- the responseTypeof the query handler which is matched against- Returns:
ResponseType.NO_MATCHif there is no match, greater than 0 if there is a match. Highest match should win when choosing a query handler.
-
responseMessagePayloadType
Description copied from interface:ResponseTypeReturns aClassrepresenting the type of the payload to be contained in the response message.- Returns:
- a
Classrepresenting the type of the payload to be contained in the response message
-
convert
Description copied from interface:ResponseTypeConverts the givenresponseof typeObjectinto the typeRof thisResponseTypeinstance. Should only be called ifResponseType.matches(Type)returns true. It is unspecified what this function does if theResponseType.matches(Type)returned false.- Parameters:
queryResponse- theObjectto convert intoR- Returns:
- a
responseof typeR
-
convertExceptional
Description copied from interface:ResponseTypeConverts the givenThrowableinto the typeRof thisResponseTypeinstance. Used when an error is represented as the message payload. TheOptionalis not empty when an error is represented as the message payload.- Returns:
- a
Optionalresponseof typeR
-
forSerialization
Description copied from interface:ResponseTypeReturns theResponseTypeinstance that should be used when serializing responses. This method has a default implementation that returnsthis. Implementations that describe a Response Type that is not suited for serialization, should return an alternative that is suitable, and ensure theResponseType.convert(Object)is capable of converting that type of response to the request type in this instance.- Returns:
- a
ResponseTypeinstance describing a type suitable for serialization
-