_05_backpressure._01_Drop Maven / Gradle / Ivy
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.smallrye.reactive:mutiny:2.5.8
package _05_backpressure;
import java.util.concurrent.Flow.Subscription;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.subscription.BackPressureStrategy;
import io.smallrye.mutiny.subscription.MultiEmitter;
import io.smallrye.mutiny.subscription.MultiSubscriber;
public class _01_Drop {
public static void main(String[] args) {
System.out.println("⚡️ Back-pressure: drop");
Multi.createFrom().emitter(emitter -> emitTooFast(emitter), BackPressureStrategy.ERROR)
.onOverflow().invoke(s -> System.out.print("🚨 ")).drop() // Comment out for some fun
.subscribe().withSubscriber(new MultiSubscriber
© 2015 - 2024 Weber Informatics LLC | Privacy Policy