Package org.axonframework.queryhandling
Class QuerySubscription<R>
java.lang.Object
org.axonframework.queryhandling.QuerySubscription<R>
- Type Parameters:
R- the type of response this query subscription contains
Encapsulates the identifying fields of a Query Handler when one is subscribed to the
QueryBus. As such contains the response type of the query handler and the complete
handler itself. The first is typically used by the QueryBus to select the right query handler when a query comes in.
The latter is used to perform the actual query.- Since:
- 3.2
- Author:
- Steven van Beelen
-
Constructor Summary
ConstructorsConstructorDescriptionQuerySubscription(Type responseType, MessageHandler<? super QueryMessage<?, R>> queryHandler) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanHandle(ResponseType<?> queryResponseType) Check if thisQuerySubscriptioncan handle the givenqueryResponseType, by calling theResponseType.matches(Type)function on it and providing the setresponseTypeof this subscription.booleanMessageHandler<? super QueryMessage<?, R>> Retrieve the query handler of this subscription as aMessageHandler.Retrieve the response type of this subscription as aType.inthashCode()
-
Constructor Details
-
QuerySubscription
public QuerySubscription(@Nonnull Type responseType, @Nonnull MessageHandler<? super QueryMessage<?, R>> queryHandler) - Parameters:
responseType- aTypeas the response type of this subscriptionqueryHandler- the subscribedMessageHandler
-
-
Method Details
-
getResponseType
Retrieve the response type of this subscription as aType.- Returns:
- the response type as a
Typetied to this subscription
-
canHandle
Check if thisQuerySubscriptioncan handle the givenqueryResponseType, by calling theResponseType.matches(Type)function on it and providing the setresponseTypeof this subscription.- Parameters:
queryResponseType- aResponseTypeto match this subscriptions it'sresponseTypeagainst- Returns:
- true of the given
queryResponseTypeitsResponseType.matches(Type)returns true, false if otherwise
-
getQueryHandler
Retrieve the query handler of this subscription as aMessageHandler.- Returns:
- the
MessageHandlertied to this subscription
-
hashCode
public int hashCode() -
equals
-