'Flux window - gracefully application shutdown

I have flow in my application thath groups request and send them in batch. Actually it is made with Flux.window operator, and I have question regarding this. How looks behaviour of window when application going to shut down ? Should I expect losted pushed events ? Or If I define timeout on window, then application will wait during window end and then shutdown ? Or maybe I could define some behaviour of app in such situation.

Thanks for any sugestions.



Solution 1:[1]

you can use the Disposable object received on subscribing the flux, to check if the flux window is completed or not.

Disposable subscribe = Flux.just(1, 2, 3)
            .map(number -> {
                    Thread.sleep(1000);
                    return number;
            })
            .subscribe();

    while (!subscribe.isDisposed() && count < 100) {
        Thread.sleep(500);
        count++;
        System.out.println("Waiting......");
    }
    System.out.println("disposable:" + subscribe.isDisposed());

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kaustubh Joshi