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.
@FunctionalInterface public interface Observer<T>
Observes the events produced by anObservable
. Once registered, it will receive all events currently in the backingRingbuffer
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
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <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 java.lang.Throwable> onError, RunnableEx onComplete)
Utility method for building anObserver
from its basic callback components.default void
onComplete()
Observes the completion event from theObservable
it is registered with.default void
onError(java.lang.Throwable throwable)
Observes an error event from theObservable
it is registered with, in the form of an exception that reflects the underlying cause.void
onNext(T t)
Observes the next event from theObservable
it is registered with.
-
-
-
Method Detail
-
of
@Nonnull static <T> Observer<T> of(@Nonnull ConsumerEx<? super T> onNext, @Nonnull ConsumerEx<? super java.lang.Throwable> onError, @Nonnull RunnableEx onComplete)
Utility method for building anObserver
from its basic callback components.
-
of
@Nonnull static <T> Observer<T> of(@Nonnull ConsumerEx<? super T> onNext)
Utility method for building anObserver
only from its data callback, with default behaviour for completion & error.
-
onNext
void onNext(@Nonnull T t)
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
default void onError(@Nonnull java.lang.Throwable throwable)
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.
-
-