Class QuerySubscription<R>

java.lang.Object
org.axonframework.queryhandling.QuerySubscription<R>
Type Parameters:
R - the type of response this query subscription contains

public class QuerySubscription<R> extends Object
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 Details

    • QuerySubscription

      public QuerySubscription(@Nonnull Type responseType, @Nonnull MessageHandler<? super QueryMessage<?,R>> queryHandler)
      Instantiate a QuerySubscription with a specific responseType and queryHandler.
      Parameters:
      responseType - a Type as the response type of this subscription
      queryHandler - the subscribed MessageHandler
  • Method Details

    • getResponseType

      public Type getResponseType()
      Retrieve the response type of this subscription as a Type.
      Returns:
      the response type as a Type tied to this subscription
    • canHandle

      public boolean canHandle(@Nonnull ResponseType<?> queryResponseType)
      Check if this QuerySubscription can handle the given queryResponseType, by calling the ResponseType.matches(Type) function on it and providing the set responseType of this subscription.
      Parameters:
      queryResponseType - a ResponseType to match this subscriptions it's responseType against
      Returns:
      true of the given queryResponseType its ResponseType.matches(Type) returns true, false if otherwise
    • getQueryHandler

      public MessageHandler<? super QueryMessage<?,R>> getQueryHandler()
      Retrieve the query handler of this subscription as a MessageHandler.
      Returns:
      the MessageHandler tied to this subscription
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object