Package org.sensorhub.api.event
Interface ISubscriptionBuilder<E extends Event>
- Type Parameters:
E
- type of event handled by this builder
public interface ISubscriptionBuilder<E extends Event>
Builder interface used to create new subscriptions for receiving events
from an event bus
.
-
Method Summary
Modifier and TypeMethodDescriptionSubscribe asynchronously with a simple consumer without flow control (back pressure) capabilitysubscribe
(Flow.Subscriber<? super E> subscriber) Subscribe asynchronously with a reactive stream subscriber that allows controlling the flow of the subscription (i.e.Subscribe asynchronously with the specified callbacks and the ability to control the flow of the subscription (i.e.Subscribe asynchronously with the specified callbacks and the ability to control the flow of the subscription (i.e.Subscribe asynchronously with the specified callbacks and the ability to control the flow of the subscription (i.e.withEventType
(Class<? extends E> type) Include only events of the specified type
This method can be called several times to include more typeswithFilter
(Predicate<? super E> filter) Filter events using a custom predicatewithTopicID
(String... topicIDs) Add one or more topics to the subscription
Topic IDs can also contain a trailing wildcard (e.g.withTopicIDs
(Iterable<String> topicIDs) Add one or more topics to the subscription
Topic IDs can also contain a trailing wildcard (e.g.
-
Method Details
-
withTopicID
Add one or more topics to the subscription
Topic IDs can also contain a trailing wildcard (e.g. "mysource/*")- Parameters:
topicIDs
- One or more topic IDs- Returns:
- This builder for chaining
-
withTopicIDs
Add one or more topics to the subscription
Topic IDs can also contain a trailing wildcard (e.g. "mysource/*")- Parameters:
topicIDs
- Collection of topics IDs to subscribe to- Returns:
- This builder for chaining
-
withEventType
Include only events of the specified type
This method can be called several times to include more types- Parameters:
type
- The accepted event types/classes- Returns:
-
withFilter
Filter events using a custom predicate- Parameters:
filter
- Event filter predicate- Returns:
- This builder for chaining
-
subscribe
Subscribe asynchronously with a reactive stream subscriber that allows controlling the flow of the subscription (i.e. by applying back pressure)- Parameters:
subscriber
- Subscriber that will receive events- Returns:
- A future that will be notified when the subscription is ready
-
subscribe
Subscribe asynchronously with the specified callbacks and the ability to control the flow of the subscription (i.e. by applying back pressure)- Parameters:
onNext
- Callback invoked every time a new event is available- Returns:
- A future that will be notified when the subscription is ready
-
subscribe
CompletableFuture<Flow.Subscription> subscribe(Consumer<? super E> onNext, Consumer<Throwable> onError) Subscribe asynchronously with the specified callbacks and the ability to control the flow of the subscription (i.e. by applying back pressure)- Parameters:
onNext
- Callback invoked every time a new event is availableonError
- Callback invoked if an error occurs while delivering events to this subscription (e.g. the onNext callback throws an exception)- Returns:
- A future that will be notified when the subscription is ready
-
subscribe
CompletableFuture<Flow.Subscription> subscribe(Consumer<? super E> onNext, Consumer<Throwable> onError, Runnable onComplete) Subscribe asynchronously with the specified callbacks and the ability to control the flow of the subscription (i.e. by applying back pressure)- Parameters:
onNext
- Callback invoked every time a new event is availableonError
- Callback invoked if an error occurs while delivering events to this subscription (e.g. the onNext callback throws an exception)onComplete
- Callback invoked when the subscription is closed by the publisher (i.e. no more events will be delivered to this subscription)- Returns:
- A future that will be notified when the subscription is ready
-
consume
Subscribe asynchronously with a simple consumer without flow control (back pressure) capability- Parameters:
consumer
- Callback that will receive the events- Returns:
- A future that will be notified when the subscription is ready
-