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 Details

    • withTopicID

      ISubscriptionBuilder<E> withTopicID(String... topicIDs)
      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

      ISubscriptionBuilder<E> withTopicIDs(Iterable<String> topicIDs)
      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

      ISubscriptionBuilder<E> withEventType(Class<? extends E> type)
      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

      ISubscriptionBuilder<E> withFilter(Predicate<? super E> filter)
      Filter events using a custom predicate
      Parameters:
      filter - Event filter predicate
      Returns:
      This builder for chaining
    • subscribe

      CompletableFuture<Flow.Subscription> subscribe(Flow.Subscriber<? super E> subscriber)
      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

      CompletableFuture<Flow.Subscription> subscribe(Consumer<? super E> onNext)
      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 available
      onError - 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 available
      onError - 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

      CompletableFuture<Flow.Subscription> consume(Consumer<? super E> consumer)
      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