How to control back pressure and control overflow

Learn how to configure overflow when the downstream cannot keep up

When a consumer cannot keep up with the pace of a publisher, there is an overflow condition. When it happens, Mutiny sends an overflow event that you can handle using the onOverflow group.

By default, it fails and propagates an exception downstream. You can change that behavior and control how the overflow is handled using the multi.onOverflow() method, such as in:

String res1 = multi
        .emitOn(executor)
        .onOverflow().buffer(10)
        .collectItems().first()
        .await().indefinitely();

String res2 = multi
        .emitOn(executor)
        .onOverflow().dropPreviousItems()
        .collectItems().first()
        .await().indefinitely();