E - Type of dispatched signal@Deprecated public final class TopicProcessor<E> extends FluxProcessor<IN,IN>
Created from share(java.lang.String, int), the TopicProcessor will authorize concurrent publishing (multi-producer)
from its receiving side Subscriber.onNext(Object).
Additionally, any of the TopicProcessor will stop the event loop thread if an error occurs.
The processor
respects the Reactive Streams contract and must not be signalled concurrently on any
onXXXX method if share(java.lang.String, int) has not been used. Each subscriber will be assigned a unique thread that will only
stop on
terminal event: Complete, Error or Cancel. If Auto-Cancel is enabled, when all
subscribers are unregistered, a cancel signal is sent to the upstream Publisher if any.
Executor can be customized and will define how many concurrent subscribers are allowed
(fixed thread). When a Subscriber requests Long.MAX, there won't be any backpressure
applied and the producer will run at risk of being throttled if the subscribers don't
catch up. With any other strictly positive demand, a subscriber will stop reading new
Next signals (Complete and Error will still be read) as soon as the demand has been
fully consumed by the publisher.
When more than 1 subscriber listens to that processor, they will all receive the exact same events if their respective demand is still strictly positive, very much like a Fan-Out scenario.
When the backlog has been completely booked and no subscribers is draining the signals, the publisher will start throttling. In effect the smaller the backlog size is defined, the smaller the difference in processing rate between subscribers must remain. Since the sequence for each subscriber will point to various ringBuffer locations, the processor knows when a backlog can't override the previously occupied slot.
| Modifier and Type | Class and Description |
|---|---|
static class |
reactor.extra.processor.EventLoopProcessor.Slot<T>
Deprecated.
A simple reusable data container.
|
static class |
TopicProcessor.Builder<T>
Deprecated.
TopicProcessor builder that can be used to create new
processors. |
Scannable.Attr<T>Disposable.Composite, Disposable.SwapOPERATOR_NAME_UNRELATED_WORDS_PATTERN| Modifier and Type | Method and Description |
|---|---|
boolean |
alive()
Deprecated.
Determine whether this
Processor can be used. |
boolean |
awaitAndShutdown()
Deprecated.
Block until all submitted tasks have completed, then do a normal
EventLoopProcessor.dispose(). |
boolean |
awaitAndShutdown(java.time.Duration timeout)
Deprecated.
Block until all submitted tasks have completed, then do a normal
EventLoopProcessor#dispose(). |
boolean |
awaitAndShutdown(long timeout,
TimeUnit timeUnit)
Deprecated.
use
awaitAndShutdown(Duration) instead |
static <E> TopicProcessor.Builder<E> |
builder()
Deprecated.
Create a new
TopicProcessor TopicProcessor.Builder with default properties. |
static <E> TopicProcessor<E> |
create()
Deprecated.
Create a new TopicProcessor using
Queues.SMALL_BUFFER_SIZE backlog size,
blockingWait Strategy and auto-cancel. |
static <E> TopicProcessor<E> |
create(String name,
int bufferSize)
Deprecated.
Create a new TopicProcessor using the provided backlog size, with a blockingWait Strategy
and auto-cancellation.
|
protected static String |
defaultName(ThreadFactory threadFactory,
Class<? extends reactor.extra.processor.EventLoopProcessor> clazz)
Deprecated.
A method to extract a name from the ThreadFactory if it turns out to be a Supplier
(in which case the supplied value string representation is used).
|
protected static ExecutorService |
defaultRequestTaskExecutor(String name)
Deprecated.
A method to create a suitable default
ExecutorService for use in implementors
requestTask(Subscription) (a cached
thread pool), reusing a main name and appending [request-task] suffix. |
protected void |
doComplete()
Deprecated.
|
protected void |
doError(Throwable t)
Deprecated.
|
long |
downstreamCount()
Deprecated.
|
Flux<E> |
drain()
Deprecated.
Drain is a hot replication of the current buffer delivered if supported.
|
Flux<IN> |
forceShutdown()
Deprecated.
Shutdown this
Processor, forcibly halting any work currently executing and discarding any tasks that have
not yet been executed. |
long |
getAvailableCapacity()
Deprecated.
|
int |
getBufferSize()
Deprecated.
|
Throwable |
getError()
Deprecated.
|
long |
getPending()
Deprecated.
Return the number of parked elements in the emitter backlog.
|
int |
hashCode()
Deprecated.
|
java.util.stream.Stream<? extends Scannable> |
inners()
Deprecated.
|
boolean |
isSerialized()
Deprecated.
|
boolean |
isTerminated()
Deprecated.
|
void |
onComplete()
Deprecated.
|
void |
onError(Throwable t)
Deprecated.
|
void |
onNext(IN o)
Deprecated.
|
void |
onSubscribe(Subscription s)
Deprecated.
|
protected void |
requestTask(Subscription s)
Deprecated.
|
void |
run()
Deprecated.
|
Object |
scanUnsafe(Scannable.Attr key)
Deprecated.
|
protected boolean |
serializeAlways()
Deprecated.
|
static <E> TopicProcessor<E> |
share(String name,
int bufferSize)
Deprecated.
Create a new shared TopicProcessor using the passed backlog size, with a blockingWait
Strategy and auto-cancellation.
|
void |
shutdown()
Deprecated.
Shutdown this active
Processor such that it can no longer be used. |
void |
subscribe(CoreSubscriber<? super E> actual)
Deprecated.
|
String |
toString()
Deprecated.
|
currentContext, dispose, hasCompleted, hasDownstreams, hasError, isIdentityProcessor, serialize, sink, sink, switchOnNext, wrapall, any, as, blockFirst, blockFirst, blockLast, blockLast, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, bufferTimeout, bufferTimeout, bufferTimeout, bufferTimeout, bufferUntil, bufferUntil, bufferUntilChanged, bufferUntilChanged, bufferUntilChanged, bufferWhen, bufferWhen, bufferWhile, cache, cache, cache, cache, cache, cache, cancelOn, cast, checkpoint, checkpoint, checkpoint, collect, collect, collectList, collectMap, collectMap, collectMap, collectMultimap, collectMultimap, collectMultimap, collectSortedList, collectSortedList, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, concat, concat, concat, concat, concatDelayError, concatDelayError, concatDelayError, concatDelayError, concatMap, concatMap, concatMapDelayError, concatMapDelayError, concatMapDelayError, concatMapIterable, concatMapIterable, concatWith, concatWithValues, contextWrite, contextWrite, count, create, create, defaultIfEmpty, defer, deferContextual, deferWithContext, delayElements, delayElements, delaySequence, delaySequence, delaySubscription, delaySubscription, delaySubscription, delayUntil, dematerialize, distinct, distinct, distinct, distinct, distinctUntilChanged, distinctUntilChanged, distinctUntilChanged, doAfterTerminate, doFinally, doFirst, doOnCancel, doOnComplete, doOnDiscard, doOnEach, doOnError, doOnError, doOnError, doOnNext, doOnRequest, doOnSubscribe, doOnTerminate, elapsed, elapsed, elementAt, elementAt, empty, error, error, error, expand, expand, expandDeep, expandDeep, filter, filterWhen, filterWhen, first, first, firstWithSignal, firstWithSignal, firstWithValue, firstWithValue, flatMap, flatMap, flatMap, flatMap, flatMapDelayError, flatMapIterable, flatMapIterable, flatMapSequential, flatMapSequential, flatMapSequential, flatMapSequentialDelayError, from, fromArray, fromIterable, fromStream, fromStream, generate, generate, generate, getPrefetch, groupBy, groupBy, groupBy, groupBy, groupJoin, handle, hasElement, hasElements, hide, ignoreElements, index, index, interval, interval, interval, interval, join, just, just, last, last, limitRate, limitRate, limitRequest, log, log, log, log, log, log, map, materialize, merge, merge, merge, merge, merge, merge, mergeDelayError, mergeOrdered, mergeOrdered, mergeOrdered, mergeOrderedWith, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequentialDelayError, mergeSequentialDelayError, mergeSequentialDelayError, mergeWith, metrics, name, never, next, ofType, onAssembly, onAssembly, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureDrop, onBackpressureDrop, onBackpressureError, onBackpressureLatest, onErrorContinue, onErrorContinue, onErrorContinue, onErrorMap, onErrorMap, onErrorMap, onErrorResume, onErrorResume, onErrorResume, onErrorReturn, onErrorReturn, onErrorReturn, onErrorStop, onTerminateDetach, or, parallel, parallel, parallel, publish, publish, publish, publish, publishNext, publishOn, publishOn, publishOn, push, push, range, reduce, reduce, reduceWith, repeat, repeat, repeat, repeat, repeatWhen, replay, replay, replay, replay, replay, replay, retry, retry, retryWhen, sample, sample, sampleFirst, sampleFirst, sampleTimeout, sampleTimeout, scan, scan, scanWith, share, shareNext, single, single, singleOrEmpty, skip, skip, skip, skipLast, skipUntil, skipUntilOther, skipWhile, sort, sort, startWith, startWith, startWith, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, subscribeOn, subscriberContext, subscriberContext, subscribeWith, switchIfEmpty, switchMap, switchMap, switchOnFirst, switchOnFirst, switchOnNext, switchOnNext, tag, take, take, take, takeLast, takeUntil, takeUntilOther, takeWhile, then, then, thenEmpty, thenMany, timeout, timeout, timeout, timeout, timeout, timeout, timeout, timestamp, timestamp, toIterable, toIterable, toIterable, toStream, toStream, transform, transformDeferred, transformDeferredContextual, using, using, usingWhen, usingWhen, window, window, window, window, window, window, window, windowTimeout, windowTimeout, windowUntil, windowUntil, windowUntil, windowUntilChanged, windowUntilChanged, windowUntilChanged, windowWhen, windowWhile, windowWhile, withLatestFrom, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipWith, zipWith, zipWith, zipWith, zipWithIterable, zipWithIterableclone, equals, finalize, getClass, notify, notifyAll, wait, wait, waitactuals, from, isScanAvailable, name, parents, scan, scanOrDefault, stepName, steps, tagsisDisposedpublic static <E> TopicProcessor.Builder<E> builder()
TopicProcessor TopicProcessor.Builder with default properties.public static <E> TopicProcessor<E> create()
Queues.SMALL_BUFFER_SIZE backlog size,
blockingWait Strategy and auto-cancel. A new Cached ThreadExecutorPool will be implicitly created.
E - Type of processed signalspublic static <E> TopicProcessor<E> create(String name, int bufferSize)
A new Cached ThreadExecutorPool will be implicitly created and will use the passed name to qualify the created threads.
E - Type of processed signalsname - Use a new Cached ExecutorService and assign this name to the created
threadsbufferSize - A Backlog Size to mitigate slow subscriberspublic static <E> TopicProcessor<E> share(String name, int bufferSize)
A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that will fan-in data.
A new Cached ThreadExecutorPool will be implicitly created and will use the passed name to qualify the created threads.
E - Type of processed signalsname - Use a new Cached ExecutorService and assign this name to the created
threadsbufferSize - A Backlog Size to mitigate slow subscriberspublic void subscribe(CoreSubscriber<? super E> actual)
public Flux<E> drain()
Flux sequence possibly unbounded of incoming buffered values or empty if not supported.protected void doError(Throwable t)
protected void doComplete()
public long getPending()
protected void requestTask(Subscription s)
public void run()
@Nullable public Object scanUnsafe(Scannable.Attr key)
scanUnsafe in interface ScannablescanUnsafe in class FluxProcessor<IN,IN>protected static String defaultName(@Nullable ThreadFactory threadFactory, Class<? extends reactor.extra.processor.EventLoopProcessor> clazz)
threadFactory - the factory to test for a supplied nameclazz - protected static ExecutorService defaultRequestTaskExecutor(String name)
ExecutorService for use in implementors
requestTask(Subscription) (a cached
thread pool), reusing a main name and appending [request-task] suffix.name - the main thread name used by the processor.ExecutorService for requestTask.public final boolean alive()
Processor can be used.Resource is alive and can be used, false otherwise.public final boolean awaitAndShutdown()
EventLoopProcessor.dispose().@Deprecated public final boolean awaitAndShutdown(long timeout, TimeUnit timeUnit)
awaitAndShutdown(Duration) insteadEventLoopProcessor#dispose().timeout - the timeout valuetimeUnit - the unit for timeoutpublic final boolean awaitAndShutdown(java.time.Duration timeout)
EventLoopProcessor#dispose().timeout - the timeout value as a Duration. Note this is converted to a Long
of nanoseconds (which amounts to roughly 292 years maximum timeout).public java.util.stream.Stream<? extends Scannable> inners()
inners in interface Scannableinners in class FluxProcessor<IN,IN>public final Flux<IN> forceShutdown()
Processor, forcibly halting any work currently executing and discarding any tasks that have
not yet been executed.public final long getAvailableCapacity()
@Nullable public final Throwable getError()
getError in class FluxProcessor<IN,IN>public boolean isSerialized()
isSerialized in class FluxProcessor<IN,IN>public final boolean isTerminated()
isTerminated in class FluxProcessor<IN,IN>public final void onComplete()
onComplete in interface Subscriber<IN>public final void onError(Throwable t)
onError in interface Subscriber<IN>public final void onNext(IN o)
onNext in interface Subscriber<IN>public final void onSubscribe(Subscription s)
onSubscribe in interface Subscriber<IN>onSubscribe in interface CoreSubscriber<IN>protected boolean serializeAlways()
serializeAlways in class FluxProcessor<IN,IN>public final void shutdown()
Processor such that it can no longer be used. If the resource carries any work, it
will wait (but NOT blocking the caller) for all the remaining tasks to perform before closing the resource.public final int getBufferSize()
getBufferSize in class FluxProcessor<IN,IN>public long downstreamCount()
downstreamCount in class FluxProcessor<IN,IN>