Package org.apache.pulsar.broker.service
Class TopicEventsDispatcher
java.lang.Object
org.apache.pulsar.broker.service.TopicEventsDispatcher
Utility class to dispatch topic events.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTopicEventListener(TopicEventsListener... listeners) Adds listeners, ignores null listeners.voidnotify(String topic, TopicEventsListener.TopicEvent event, TopicEventsListener.EventStage stage) Dispatches notification to all currently added listeners.voidnotify(String topic, TopicEventsListener.TopicEvent event, TopicEventsListener.EventStage stage, Throwable t) Dispatches notification to all currently added listeners.static voidnotify(TopicEventsListener[] listeners, String topic, TopicEventsListener.TopicEvent event, TopicEventsListener.EventStage stage, Throwable t) Dispatches notification to specified listeners.<T> CompletableFuture<T>notifyOnCompletion(CompletableFuture<T> future, String topic, TopicEventsListener.TopicEvent event) Dispatches SUCCESS/FAILURE notification to all currently added listeners on completion of the future.voidremoveTopicEventListener(TopicEventsListener... listeners) Removes listeners.
-
Constructor Details
-
TopicEventsDispatcher
public TopicEventsDispatcher()
-
-
Method Details
-
addTopicEventListener
Adds listeners, ignores null listeners.- Parameters:
listeners-
-
removeTopicEventListener
Removes listeners.- Parameters:
listeners-
-
notify
public void notify(String topic, TopicEventsListener.TopicEvent event, TopicEventsListener.EventStage stage) Dispatches notification to all currently added listeners.- Parameters:
topic-event-stage-
-
notify
public void notify(String topic, TopicEventsListener.TopicEvent event, TopicEventsListener.EventStage stage, Throwable t) Dispatches notification to all currently added listeners.- Parameters:
topic-event-stage-t-
-
notifyOnCompletion
public <T> CompletableFuture<T> notifyOnCompletion(CompletableFuture<T> future, String topic, TopicEventsListener.TopicEvent event) Dispatches SUCCESS/FAILURE notification to all currently added listeners on completion of the future.- Type Parameters:
T-- Parameters:
future-topic-event-- Returns:
- future of a new completion stage
-
notify
public static void notify(TopicEventsListener[] listeners, String topic, TopicEventsListener.TopicEvent event, TopicEventsListener.EventStage stage, Throwable t) Dispatches notification to specified listeners.- Parameters:
listeners-topic-event-stage-t-
-