This application illustrates how to use the retry interceptor to retry failed invocations and make the application resilient to failures.
The server is configured to randomly fail with DispatchException(StatusCode.Unavailable), which can only be retried
on a different server address. The retry interceptor will automatically retry failed invocations up to the configured
max attempts. If the retry interceptor reaches the max retry attempts, or if it exhausted all available server
addresses, it gives up on retrying and reports the failure.
This example uses QUIC, IceRPC's default multiplexed transport. On Linux and macOS, QUIC requires extra setup steps; see .NET's QUIC platform dependencies.
You can build the client and server applications with:
dotnet buildFirst start at least two instances of the Server:
cd Server
dotnet run -- 0In a separate terminal, start the second instance:
cd Server
dotnet run -- 1You can start additional instances of the Server, using consecutive numbers:
cd Server
dotnet run -- 2In a separate terminal, start the Client program, passing the number of server instances as an argument:
cd Client
dotnet run -- 3The client will continue sending invocations until you stop it with Ctrl+C, or until the invocation fails because the retry interceptor cannot recover from the failure, which can happen if the retry interceptor reaches the max retry attempts, or if it has exhausted all available server addresses.
You can also stop some of the servers while the client is running. The client will keep sending invocations unless all
remaining servers throw DispatchException(StatusCode.Unavailable).