Add WebFlux WebClient Support
Would be nice to add a link and some non feign usage examples.
This is the same as the reactive support. WebFlux is Spring's reactive HTTP Client. For now, you can write your own Client to use it, but the request will not be "reactive all the way down". We spoken about this at length about it here: https://github.com/OpenFeign/feign/issues/361 and here: https://github.com/OpenFeign/feign/issues/1120
In short, core Feign will need to be updated to support this.
@kdavisk6 Thank you, I see it. What is the progress now for the reactive support. Can you give me some examples?
@SnowZhouJ Sure. You can find a lot of examples here https://github.com/Playtika/feign-reactive
@kptfh Are declarative annotations now supported? Like @FeignClient
Yes. Spring auto configuration is fully supported. Check tests for examples. Btw Playtika is using it in prod. Here is the basic sample https://github.com/kptfh/feign-reactive-sample
@kptfh Application run Failed , Error info:
nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class reactivefeign.spring.config.ReactiveFeignClientsConfiguration
Is Spring Cloud Version Error ?
Take the last version of https://github.com/Playtika/feign-reactive Now it supports Hoxton and 2.2.2 Spring boot
I tried to create a new project,Use Hoxton.RELEASE and 2.2.2.RELEASE Spring boot ,But Still failed to start,this is error info
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [reactivefeign.spring.config.ReactiveFeignClientsConfiguration]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class reactivefeign.spring.config.ReactiveFeignClientsConfiguration
@SnowZhouJ Can you update or close this issue as it's already fixed in feign-reactive
@kptfh
- I'm getting an error (Could not autowire. No beans of 'CustomerClient' type found.) in IntellijIdea when using
@ReactiveFeignClient (name="customer-service")
public interface CustomerClient {
@GetMapping("/service/department/{departmentId}")
Flux<Customer> findByDepartment(@PathVariable("departmentId") Long departmentId);
}
and injecting it in constructor in another class (Service layer) as:
private CustomerClient customerClient;
@Autowired
public DepartmentService (CustomerClient customerClient) {
this.customerClient=customerClient;
}
- Does it support fallbackFactory in parameters as it was in OpenFeign. For instance,
@FeignClient(name = "department-service", fallbackFactory = CustomerClientFallbackFactory.class)
if not how can fallback classes be written? *I'm using spring-cloud.version: Hoxton.SR1 and feign-reactor.version: 1.0.44
- Annotation @EnableReactiveFeignClients is already included. No changes. The warning still exists.
@SpringBootApplication
@EnableDiscoveryClient
@EnableReactiveFeignClients
@EnableHystrix
public class DepartmentServiceApplication {
public static void main(String[] args) {
SpringApplication.run(DepartmentServiceApplication.class, args);
}
}
The warning disappears only when interface is annotated with @ Component annotation.
@paro87 Check this sample project
@kptfh I encountered with above mentioned bean problem while including FallbackFactory to the parameters as:
@FeignClient(name = "service_statistics", fallbackFactory = StatisticFallbackFactory.class)
public interface ServiceFeignClient {
@GetMapping("/users/{id}/statistics")
public List<UserModel> getStatistics(@PathVariable String id);
}
where in OpenFeign FallbackFactory comes from feign.hystrix
import feign.hystrix.FallbackFactory;
@Component
public class StatisticFallbackFactory implements FallbackFactory<ServiceFeignClient> {
@Override
public ServiceFeignClient create(Throwable cause) {
return new ServiceFeignClientFallback(cause);
}
}
but in Reactive one, it comes from reactivefeign.FallbackFactory. Maybe there is some Hystrix support problem or bean conflict that causes that error. Shortly speaking, "example1" and "example2" (adapted to ReactiveFeign) from this repository https://github.com/ksereda/Spring_Cloud_Netflix_Microservices/tree/master/hystrix works fine, but the problem occurs in "example3".
@paro87 please, create the issue in the reactive feign repo. I would appreciate if you create not working example (you may use fork of the sample project)
@paro87 Hi paro! I will close this issue, please create new issue in the reactive feign repo( feign-reactive).