- All Known Subinterfaces:
Knowledge,RuleSession<S>,RuleSetContext<C,,R> RuntimeContext<C>,StatefulSession,StatelessSession
- All Known Implementing Classes:
org.evrete.runtime.AbstractKnowledgeService,AbstractSessionWrapper,KnowledgeService,KnowledgeWrapper
public interface EventBus
Interface representing an Event Bus for subscribing to events.
-
Method Summary
Modifier and TypeMethodDescription<E extends ContextEvent>
Events.Publisher<E>getPublisher(Class<E> eventClass) Returns a publisher for a specific event class type.default <E extends ContextEvent>
Events.SubscriptionSubscribes an even consumer to a specific event class type.default <E extends ContextEvent>
Events.Subscriptiondefault <E extends ContextEvent>
Events.SubscriptionsubscribeAsync(Class<E> eventClass, Consumer<E> consumer)
-
Method Details
-
subscribe
default <E extends ContextEvent> Events.Subscription subscribe(Class<E> eventClass, boolean async, Consumer<E> consumer) Subscribes an even consumer to a specific event class type.When an event of the specified type is published, the consumer will be invoked.
The consumer can be notified asynchronously based on the
asyncparameter.- Type Parameters:
E- the type of the event to listen for- Parameters:
eventClass- the class object of the event typeasync- iftrue, the consumer will be invoked asynchronously using theAbstractKnowledgeService.getExecutor(); iffalse, it will be invoked synchronouslyconsumer- the consumer that will handle events of the specified type- Returns:
- a
Events.Subscriptionthat can be used to unsubscribe the consumer from the event type - Throws:
IllegalArgumentException- if the provided event class is not supported- See Also:
-
getPublisher
Returns a publisher for a specific event class type.- Type Parameters:
E- the type of the event to publish- Parameters:
eventClass- the class object of the event type- Returns:
- an
Events.Publisherfor the specified event class type - Throws:
IllegalArgumentException- if the provided event class is not supported- See Also:
-
subscribe
default <E extends ContextEvent> Events.Subscription subscribe(Class<E> eventClass, Consumer<E> consumer) -
subscribeAsync
default <E extends ContextEvent> Events.Subscription subscribeAsync(Class<E> eventClass, Consumer<E> consumer)
-