Skip to content
This repository has been archived by the owner on Mar 7, 2020. It is now read-only.

Add WebFlux WebClient Support #20

Closed
SnowZhouJ opened this issue Dec 12, 2019 · 17 comments
Closed

Add WebFlux WebClient Support #20

SnowZhouJ opened this issue Dec 12, 2019 · 17 comments
Labels
documentation Should be documented enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@SnowZhouJ
Copy link

No description provided.

@velo velo added documentation Should be documented enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Dec 12, 2019
@velo
Copy link
Member

velo commented Dec 12, 2019

Would be nice to add a link and some non feign usage examples.

@kdavisk6
Copy link
Member

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: OpenFeign/feign#361 and here: OpenFeign/feign#1120

In short, core Feign will need to be updated to support this.

@SnowZhouJ
Copy link
Author

@kdavisk6 Thank you, I see it. What is the progress now for the reactive support. Can you give me some examples?

@kptfh
Copy link
Collaborator

kptfh commented Dec 13, 2019

@SnowZhouJ Sure. You can find a lot of examples here
https://github.com/Playtika/feign-reactive

@SnowZhouJ
Copy link
Author

@kptfh Are declarative annotations now supported? Like @FeignClient

@kptfh
Copy link
Collaborator

kptfh commented Dec 13, 2019

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

@SnowZhouJ
Copy link
Author

@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 ?

@kptfh
Copy link
Collaborator

kptfh commented Dec 13, 2019

Take the last version of https://github.com/Playtika/feign-reactive
Now it supports Hoxton and 2.2.2 Spring boot

@SnowZhouJ
Copy link
Author

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

@kptfh
Copy link
Collaborator

kptfh commented Jan 2, 2020

@SnowZhouJ Can you update or close this issue as it's already fixed in
feign-reactive

@paro87
Copy link

paro87 commented Jan 3, 2020

@kptfh

  1. 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;
    }
  1. 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

@paro87
Copy link

paro87 commented Jan 6, 2020

  1. 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.

@kptfh
Copy link
Collaborator

kptfh commented Jan 6, 2020

@paro87
Copy link

paro87 commented Jan 7, 2020

@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".

@kptfh
Copy link
Collaborator

kptfh commented Jan 7, 2020

@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)

@SnowZhouJ
Copy link
Author

@paro87 Hi paro! I will close this issue, please create new issue in the reactive feign repo( feign-reactive).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Should be documented enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants