@Test public void should_retry_using_default() { ExchangeFilterFunction filter = InstanceExchangeFilterFunctions.retry(1, emptyMap()); ClientRequest request = ClientRequest.create(HttpMethod.GET, URI.create("/test")).build(); ClientResponse response = mock(ClientResponse.class); AtomicLong invocationCount = new AtomicLong(0L); ExchangeFunction exchange = r -> Mono.fromSupplier(() -> { if (invocationCount.getAndIncrement() == 0) { throw new IllegalStateException("Test"); } return response; }); StepVerifier.create(filter.filter(request, exchange)).expectNext(response).verifyComplete(); assertThat(invocationCount.get()).isEqualTo(2); }
public static ExchangeFilterFunction retry(int defaultRetries, Map<String, Integer> retriesPerEndpoint) { return (request, next) -> { int retries = 0; if (!request.method().equals(HttpMethod.DELETE) && !request.method().equals(HttpMethod.PATCH) && !request.method().equals(HttpMethod.POST) && !request.method().equals(HttpMethod.PUT)) { retries = request.attribute(ATTRIBUTE_ENDPOINT).map(retriesPerEndpoint::get).orElse(defaultRetries); } return next.exchange(request).retry(retries); }; }
InstanceExchangeFilterFunctions { public static ExchangeFilterFunction retry(int defaultRetries, Map<String, Integer> retriesPerEndpoint) { return (request, next) -> { int retries = 0; if (!request.method().equals(HttpMethod.DELETE) && !request.method().equals(HttpMethod.PATCH) && !request.method().equals(HttpMethod.POST) && !request.method().equals(HttpMethod.PUT)) { retries = request.attribute(ATTRIBUTE_ENDPOINT).map(retriesPerEndpoint::get).orElse(defaultRetries); } return next.exchange(request).retry(retries); }; } }
InstanceExchangeFilterFunctions { public static ExchangeFilterFunction retry(int defaultRetries, Map<String, Integer> retriesPerEndpoint) { return (request, next) -> { int retries = 0; if (!request.method().equals(HttpMethod.DELETE) && !request.method().equals(HttpMethod.PATCH) && !request.method().equals(HttpMethod.POST) && !request.method().equals(HttpMethod.PUT)) { retries = request.attribute(ATTRIBUTE_ENDPOINT).map(retriesPerEndpoint::get).orElse(defaultRetries); } return next.exchange(request).retry(retries); }; } private  InstanceExchangeFilterFunctions(); }
InstanceExchangeFilterFunctions { public static ExchangeFilterFunction retry(int defaultRetries, Map<String, Integer> retriesPerEndpoint) { return (request, next) -> { int retries = 0; if (!request.method().equals(HttpMethod.DELETE) && !request.method().equals(HttpMethod.PATCH) && !request.method().equals(HttpMethod.POST) && !request.method().equals(HttpMethod.PUT)) { retries = request.attribute(ATTRIBUTE_ENDPOINT).map(retriesPerEndpoint::get).orElse(defaultRetries); } return next.exchange(request).retry(retries); }; } private  InstanceExchangeFilterFunctions(); static ExchangeFilterFunction setInstance(Instance instance); static ExchangeFilterFunction setInstance(Mono<Instance> instance); static ExchangeFilterFunction addHeaders(HttpHeadersProvider httpHeadersProvider); static ExchangeFilterFunction toExchangeFilterFunction(InstanceExchangeFilterFunction delegate); static ExchangeFilterFunction rewriteEndpointUrl(); static ExchangeFilterFunction convertLegacyEndpoint(LegacyEndpointConverter converter); static ExchangeFilterFunction setDefaultAcceptHeader(); static ExchangeFilterFunction retry(int defaultRetries, Map<String, Integer> retriesPerEndpoint); }
InstanceExchangeFilterFunctions { public static ExchangeFilterFunction retry(int defaultRetries, Map<String, Integer> retriesPerEndpoint) { return (request, next) -> { int retries = 0; if (!request.method().equals(HttpMethod.DELETE) && !request.method().equals(HttpMethod.PATCH) && !request.method().equals(HttpMethod.POST) && !request.method().equals(HttpMethod.PUT)) { retries = request.attribute(ATTRIBUTE_ENDPOINT).map(retriesPerEndpoint::get).orElse(defaultRetries); } return next.exchange(request).retry(retries); }; } private  InstanceExchangeFilterFunctions(); static ExchangeFilterFunction setInstance(Instance instance); static ExchangeFilterFunction setInstance(Mono<Instance> instance); static ExchangeFilterFunction addHeaders(HttpHeadersProvider httpHeadersProvider); static ExchangeFilterFunction toExchangeFilterFunction(InstanceExchangeFilterFunction delegate); static ExchangeFilterFunction rewriteEndpointUrl(); static ExchangeFilterFunction convertLegacyEndpoint(LegacyEndpointConverter converter); static ExchangeFilterFunction setDefaultAcceptHeader(); static ExchangeFilterFunction retry(int defaultRetries, Map<String, Integer> retriesPerEndpoint); static final String ATTRIBUTE_INSTANCE; static final String ATTRIBUTE_ENDPOINT; }