### Building a Feign Client Source: https://github.com/playtikaoss/feign-reactive/blob/develop/README.md Example of how to build a Feign client instance using WebReactiveFeign. ```java /* Create instance of your API */ IcecreamServiceApi client = WebReactiveFeign //WebClient based reactive feign //JettyReactiveFeign //Jetty http client based //Java11ReactiveFeign //Java 11 http client based .builder() .target(IcecreamServiceApi.class, "http://www.icecreame.com") /* Execute nonblocking requests */ Flux flavors = icecreamApi.getAvailableFlavors(); Flux mixins = icecreamApi.getAvailableMixins(); ``` -------------------------------- ### Feign API Example Source: https://github.com/playtikaoss/feign-reactive/blob/develop/README.md Example of how to define a Feign API interface with reactive types. ```java import feign.Headers; import feign.Param; import feign.RequestLine; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; public interface IcecreamServiceApi { @Headers({ "Accept: application/json" }) Flux getAvailableFlavors(); @RequestLine("GET /icecream/mixins") Flux getAvailableMixins(); @RequestLine("POST /icecream/orders") @Headers("Content-Type: application/json") Mono makeOrder(IceCreamOrder order); @RequestLine("GET /icecream/orders/{orderId}") Mono findOrder(@Param("orderId") int orderId); @RequestLine("POST /icecream/bills/pay") @Headers("Content-Type: application/json") Mono payBill(Publisher bill); } ``` -------------------------------- ### Building a Cloud-Aware Feign Client Source: https://github.com/playtikaoss/feign-reactive/blob/develop/README.md Example of building a cloud-aware Feign client with fallback and load balancing. ```java IcecreamServiceApi client = CloudReactiveFeign.builder(WebReactiveFeign.builder()) .setLoadBalancerCommandFactory(s -> LoadBalancerCommand.builder() .withLoadBalancer(AbstractLoadBalancer.class.cast(getNamedLoadBalancer(serviceName))) .withRetryHandler(new DefaultLoadBalancerRetryHandler(1, 1, true)) .build()) .fallback(() -> Mono.just(new IcecreamServiceApi() { @Override public Mono get() { return Mono.just("fallback"); } })) .target(IcecreamServiceApi.class, "http://" + serviceName); /* Execute nonblocking requests */ Flux flavors = icecreamApi.getAvailableFlavors(); Flux mixins = icecreamApi.getAvailableMixins(); ``` -------------------------------- ### application.properties configuration for retry Source: https://github.com/playtikaoss/feign-reactive/blob/develop/feign-reactor-spring-configuration/README.md Example properties to configure retry settings for a specific Feign client, including max retries and backoff period. ```properties reactive.feign.client.config..retry.builder=reactivefeign.retry.BasicReactiveRetryPolicy.Builder reactive.feign.client.config..retry.args.maxRetries=2 reactive.feign.client.config..retry.args.backoffInMs=10 ``` -------------------------------- ### Building and Using Rx2ReactiveFeign Client Source: https://github.com/playtikaoss/feign-reactive/blob/develop/README.md Demonstrates how to build an instance of the Feign API client and execute non-blocking requests using RxJava types. ```java /* Create instance of your API */ IcecreamServiceApi client = Rx2ReactiveFeign .builder() .target(IcecreamServiceApi.class, "http://www.icecreame.com") /* Execute nonblocking requests */ Flowable flavors = icecreamApi.getAvailableFlavors(); Observable mixins = icecreamApi.getAvailableMixins(); ``` -------------------------------- ### Adding Headers with ReactiveHttpRequestInterceptor Source: https://github.com/playtikaoss/feign-reactive/blob/develop/README.md Shows how to add custom headers to requests using ReactiveFeignBuilder and ReactiveHttpRequestInterceptor, including dynamic headers like Authorization. ```java ReactiveFeignBuilder .addRequestInterceptor(ReactiveHttpRequestInterceptors.addHeader("Cache-Control", "no-cache")) .addRequestInterceptor(request -> Mono .subscriberContext() .map(ctx -> ctx .getOrEmpty("authToken") .map(authToken -> { MultiValueMapUtils.addOrdered(request.headers(), "Authorization", authToken); return request; }) .orElse(request))); ``` -------------------------------- ### Rx2 or Rx3 Feign API Definition Source: https://github.com/playtikaoss/feign-reactive/blob/develop/README.md Defines a Feign API interface with methods that accept and return RxJava types like Flowable, Observable, Single, and Maybe. ```java @Headers({"Accept: application/json"}) public interface IcecreamServiceApi { @RequestLine("GET /icecream/flavors") Flowable getAvailableFlavors(); @RequestLine("GET /icecream/mixins") Observable getAvailableMixins(); @RequestLine("POST /icecream/orders") @Headers("Content-Type: application/json") Single makeOrder(IceCreamOrder order); @RequestLine("GET /icecream/orders/{orderId}") Maybe findOrder(@Param("orderId") int orderId); @RequestLine("POST /icecream/bills/pay") @Headers("Content-Type: application/json") Single payBill(Bill bill); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.