use of reactor.core.publisher.FluxSink.OverflowStrategy.DROP in project reactor-core by reactor.
the class FluxSubscribeOnTest method forceScheduledRequests.
@Test
public void forceScheduledRequests() {
Flux<Integer> test = Flux.<Integer>create(sink -> {
for (int i = 1; i < 1001; i++) {
sink.next(i);
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
sink.complete();
}, DROP).map(Function.identity()).subscribeOn(Schedulers.single(), true).publishOn(Schedulers.elastic());
AtomicInteger count = new AtomicInteger();
StepVerifier.create(test).thenConsumeWhile(t -> count.incrementAndGet() != -1).expectComplete().verify(Duration.ofSeconds(5));
assertThat(count.get()).isEqualTo(Queues.SMALL_BUFFER_SIZE);
}
use of reactor.core.publisher.FluxSink.OverflowStrategy.DROP in project reactor-core by reactor.
the class FluxSubscribeOnTest method forceNoScheduledRequests.
@Test
public void forceNoScheduledRequests() {
Flux<Integer> test = Flux.<Integer>create(sink -> {
for (int i = 1; i < 1001; i++) {
sink.next(i);
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
sink.complete();
}, DROP).map(Function.identity()).subscribeOn(Schedulers.single(), false).publishOn(Schedulers.elastic());
AtomicInteger count = new AtomicInteger();
StepVerifier.create(test).thenConsumeWhile(t -> count.incrementAndGet() != -1).expectComplete().verify(Duration.ofSeconds(5));
assertThat(count.get()).isGreaterThan(Queues.SMALL_BUFFER_SIZE);
}
Aggregations