Interface Observer<T>
- Type Parameters:
T
- type of the observed event
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Observable
. Once registered,
it will receive all events currently in the backing Ringbuffer
and then continue receiving any future events.
Jet calls this Observer
's callbacks on an internal thread pool
of limited size, shared with many other Hazelcast Jet services. Therefore
the callbacks should take care to finish as quickly as possible.
- Since:
- Jet 4.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Observer<T>
of
(ConsumerEx<? super T> onNext) Utility method for building anObserver
only from its data callback, with default behaviour for completion & error.static <T> Observer<T>
of
(ConsumerEx<? super T> onNext, ConsumerEx<? super Throwable> onError, RunnableEx onComplete) Utility method for building anObserver
from its basic callback components.default void
Observes the completion event from theObservable
it is registered with.default void
Observes an error event from theObservable
it is registered with, in the form of an exception that reflects the underlying cause.void
Observes the next event from theObservable
it is registered with.
-
Method Details
-
of
@Nonnull static <T> Observer<T> of(@Nonnull ConsumerEx<? super T> onNext, @Nonnull ConsumerEx<? super Throwable> onError, @Nonnull RunnableEx onComplete) Utility method for building anObserver
from its basic callback components. -
of
Utility method for building anObserver
only from its data callback, with default behaviour for completion & error. -
onNext
Observes the next event from theObservable
it is registered with.Although the
Observable
respects the order of events published to it, the publication order itself is generally non-deterministic. A Jet pipeline must be written with the specific goal of order preservation in mind. For example, a map/filter stage that doesn't explicitly set its local parallelism to 1 will reorder the data.After this observer has seen an error or completion event, it will see no further events.
-
onError
Observes an error event from theObservable
it is registered with, in the form of an exception that reflects the underlying cause.After this observer has seen an error or completion event, it will see no further events.
-
onComplete
default void onComplete()Observes the completion event from theObservable
it is registered with. Only an observer attached to a batch job will ever see this event. Unbounded streaming jobs never complete without error.After this observer has seen an error or completion event, it will see no further events.
-