Reactor – Handle Error

In this tutorial, JavaSampleApproach introduce ways to handle Errors: catch Exception and fall back, recover from errors, deal with backpressure errors…

I. Ways to handle Errors

0. Declare & Initialize Flux

1. Catching Exception
1.1 Then do something

1.2 Then fall back to a default value

1.3 Then re-throw new Exception

2. Recover from Errors
2.1 By falling back to another Flux

2.2 By retrying

With Predicate:

3. Deal with Backpressure Errors
3.1 By throwing a special Exception

When Receiver is overrun by more signals than expected:

3.2 By dropping excess values

3.2 By buffering excess values

II. Source Code

1. Technology

– Java 8
– Maven 3.6.1
– Reactor Core 3.0.4, with the Aluminium release train.

2. Reactor installation in Maven

– First, import the BOM by adding the following to pom.xml:

– Next, add dependency:

3. Code

4. Results


Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*