Interface QueryResolver
-
- All Known Implementing Classes:
QueryResolverImpl
public interface QueryResolverAQueryResolverallows sendingQueryon an synchronousMessageBus.- See Also:
- EventMaid Documentation
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends Query<?>>
SubscriptionIdanswer(Class<T> queryClass, Consumer<T> responder)Adds a newConsumerasSubscriberforthe givenQueryclass.<R> Optional<R>query(Query<R> query)Sends theQueryto all interestedSubscribers.<R> RqueryRequired(Query<R> query)Sends theQueryto all interestedSubscribers.voidunsubscribe(SubscriptionId subscriptionId)Method to remove allConsumermatching theSubscriptionId.
-
-
-
Method Detail
-
query
<R> Optional<R> query(Query<R> query)
Sends theQueryto all interestedSubscribers. This method does not need to return an result.- Type Parameters:
R- the type of the result- Parameters:
query- theQueryto be sent- Returns:
- an
Optionalfor theQueryresult
-
queryRequired
<R> R queryRequired(Query<R> query)
Sends theQueryto all interestedSubscribers. This method expects a valid result.- Type Parameters:
R- the type of the result- Parameters:
query- theQueryto be sent- Returns:
- the
Queryresult - Throws:
UnsupportedOperationException- if not result was received
-
answer
<T extends Query<?>> SubscriptionId answer(Class<T> queryClass, Consumer<T> responder)
Adds a newConsumerasSubscriberforthe givenQueryclass.- Type Parameters:
T- the type of the query- Parameters:
queryClass- the class of theQueryresponder- theConsumerto answer the query- Returns:
- a
SubscriptionIdof theSubscriber
-
unsubscribe
void unsubscribe(SubscriptionId subscriptionId)
Method to remove allConsumermatching theSubscriptionId.- Parameters:
subscriptionId- theSubscriptionIdto remove
-
-