Class ReactiveCircuitBreakerAdapterDecorator

java.lang.Object
org.springframework.web.service.invoker.HttpExchangeAdapterDecorator
org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
org.springframework.cloud.client.circuitbreaker.httpservice.ReactiveCircuitBreakerAdapterDecorator
All Implemented Interfaces:
org.springframework.web.service.invoker.HttpExchangeAdapter, org.springframework.web.service.invoker.ReactorHttpExchangeAdapter

public class ReactiveCircuitBreakerAdapterDecorator extends org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
Reactive implementation of HttpExchangeAdapterDecorator that wraps @HttpExchange

In the event of a CircuitBreaker fallback, this class uses the user-provided fallback class to create a proxy. The fallback method is selected by matching either:

  • A method with the same name and argument types as the original method, or
  • A method with the same name and the original arguments preceded by a Throwable, allowing the user to access the cause of failure within the fallback.
Once a matching method is found, it is invoked to provide the fallback behavior. Both the fallback class and the fallback methods must be public.

Since:
5.0.0
Author:
Olga Maciaszek-Sharma
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReactiveCircuitBreakerAdapterDecorator(org.springframework.web.service.invoker.ReactorHttpExchangeAdapter delegate, ReactiveCircuitBreaker reactiveCircuitBreaker, CircuitBreaker circuitBreaker, Map<String,Class<?>> fallbackClasses)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    exchange(org.springframework.web.service.invoker.HttpRequestValues requestValues)
     
    org.springframework.http.ResponseEntity<Void>
    exchangeForBodilessEntity(org.springframework.web.service.invoker.HttpRequestValues values)
     
    reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Void>>
    exchangeForBodilessEntityMono(org.springframework.web.service.invoker.HttpRequestValues requestValues)
     
    <T> @Nullable T
    exchangeForBody(org.springframework.web.service.invoker.HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)
     
    <T> reactor.core.publisher.Flux<T>
    exchangeForBodyFlux(org.springframework.web.service.invoker.HttpRequestValues requestValues, org.springframework.core.ParameterizedTypeReference<T> bodyType)
     
    <T> reactor.core.publisher.Mono<T>
    exchangeForBodyMono(org.springframework.web.service.invoker.HttpRequestValues requestValues, org.springframework.core.ParameterizedTypeReference<T> bodyType)
     
    <T> org.springframework.http.ResponseEntity<T>
    exchangeForEntity(org.springframework.web.service.invoker.HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)
     
    <T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<reactor.core.publisher.Flux<T>>>
    exchangeForEntityFlux(org.springframework.web.service.invoker.HttpRequestValues requestValues, org.springframework.core.ParameterizedTypeReference<T> bodyType)
     
    <T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<T>>
    exchangeForEntityMono(org.springframework.web.service.invoker.HttpRequestValues requestValues, org.springframework.core.ParameterizedTypeReference<T> bodyType)
     
    org.springframework.http.HttpHeaders
    exchangeForHeaders(org.springframework.web.service.invoker.HttpRequestValues values)
     
    reactor.core.publisher.Mono<org.springframework.http.HttpHeaders>
    exchangeForHeadersMono(org.springframework.web.service.invoker.HttpRequestValues requestValues)
     
    reactor.core.publisher.Mono<Void>
    exchangeForMono(org.springframework.web.service.invoker.HttpRequestValues requestValues)
     

    Methods inherited from class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator

    getBlockTimeout, getHttpExchangeAdapter, getReactiveAdapterRegistry, supportsRequestAttributes

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ReactiveCircuitBreakerAdapterDecorator

      public ReactiveCircuitBreakerAdapterDecorator(org.springframework.web.service.invoker.ReactorHttpExchangeAdapter delegate, ReactiveCircuitBreaker reactiveCircuitBreaker, CircuitBreaker circuitBreaker, Map<String,Class<?>> fallbackClasses)
  • Method Details

    • exchange

      public void exchange(org.springframework.web.service.invoker.HttpRequestValues requestValues)
      Specified by:
      exchange in interface org.springframework.web.service.invoker.HttpExchangeAdapter
      Overrides:
      exchange in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForHeaders

      public org.springframework.http.HttpHeaders exchangeForHeaders(org.springframework.web.service.invoker.HttpRequestValues values)
      Specified by:
      exchangeForHeaders in interface org.springframework.web.service.invoker.HttpExchangeAdapter
      Overrides:
      exchangeForHeaders in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForBody

      public <T> @Nullable T exchangeForBody(org.springframework.web.service.invoker.HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)
      Specified by:
      exchangeForBody in interface org.springframework.web.service.invoker.HttpExchangeAdapter
      Overrides:
      exchangeForBody in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForBodilessEntity

      public org.springframework.http.ResponseEntity<Void> exchangeForBodilessEntity(org.springframework.web.service.invoker.HttpRequestValues values)
      Specified by:
      exchangeForBodilessEntity in interface org.springframework.web.service.invoker.HttpExchangeAdapter
      Overrides:
      exchangeForBodilessEntity in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForEntity

      public <T> org.springframework.http.ResponseEntity<T> exchangeForEntity(org.springframework.web.service.invoker.HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)
      Specified by:
      exchangeForEntity in interface org.springframework.web.service.invoker.HttpExchangeAdapter
      Overrides:
      exchangeForEntity in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForMono

      public reactor.core.publisher.Mono<Void> exchangeForMono(org.springframework.web.service.invoker.HttpRequestValues requestValues)
      Specified by:
      exchangeForMono in interface org.springframework.web.service.invoker.ReactorHttpExchangeAdapter
      Overrides:
      exchangeForMono in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForHeadersMono

      public reactor.core.publisher.Mono<org.springframework.http.HttpHeaders> exchangeForHeadersMono(org.springframework.web.service.invoker.HttpRequestValues requestValues)
      Specified by:
      exchangeForHeadersMono in interface org.springframework.web.service.invoker.ReactorHttpExchangeAdapter
      Overrides:
      exchangeForHeadersMono in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForBodyMono

      public <T> reactor.core.publisher.Mono<T> exchangeForBodyMono(org.springframework.web.service.invoker.HttpRequestValues requestValues, org.springframework.core.ParameterizedTypeReference<T> bodyType)
      Specified by:
      exchangeForBodyMono in interface org.springframework.web.service.invoker.ReactorHttpExchangeAdapter
      Overrides:
      exchangeForBodyMono in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForBodyFlux

      public <T> reactor.core.publisher.Flux<T> exchangeForBodyFlux(org.springframework.web.service.invoker.HttpRequestValues requestValues, org.springframework.core.ParameterizedTypeReference<T> bodyType)
      Specified by:
      exchangeForBodyFlux in interface org.springframework.web.service.invoker.ReactorHttpExchangeAdapter
      Overrides:
      exchangeForBodyFlux in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForBodilessEntityMono

      public reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Void>> exchangeForBodilessEntityMono(org.springframework.web.service.invoker.HttpRequestValues requestValues)
      Specified by:
      exchangeForBodilessEntityMono in interface org.springframework.web.service.invoker.ReactorHttpExchangeAdapter
      Overrides:
      exchangeForBodilessEntityMono in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForEntityMono

      public <T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<T>> exchangeForEntityMono(org.springframework.web.service.invoker.HttpRequestValues requestValues, org.springframework.core.ParameterizedTypeReference<T> bodyType)
      Specified by:
      exchangeForEntityMono in interface org.springframework.web.service.invoker.ReactorHttpExchangeAdapter
      Overrides:
      exchangeForEntityMono in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator
    • exchangeForEntityFlux

      public <T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<reactor.core.publisher.Flux<T>>> exchangeForEntityFlux(org.springframework.web.service.invoker.HttpRequestValues requestValues, org.springframework.core.ParameterizedTypeReference<T> bodyType)
      Specified by:
      exchangeForEntityFlux in interface org.springframework.web.service.invoker.ReactorHttpExchangeAdapter
      Overrides:
      exchangeForEntityFlux in class org.springframework.web.service.invoker.ReactorHttpExchangeAdapterDecorator