What is a declarative HTTP client vs. an imperative one? Why are they useful and why should I care? We’ll talk about options that are available in the Spring portfolio and what’s coming on the horizon. In this session, we’ll look at the history of declarative clients in Spring via Spring Cloud OpenFeign. We’ll also dive into upcoming options that are coming to Spring and the advantages that these new technologies bring to the developer experience. Spring One Tour Tel-Aviv 2022.
2. About Olga
Software Engineer in Spring Cloud team
Spring Cloud LoadBalancer, Spring Cloud OpenFeign, Spring
Cloud Netflix, Spring Cloud Contract, Spring Cloud Square,
RSocket HTTP Bridge
TT/ Mastodon: @olga_maciaszek
14. Feign
Java to HTTP client binder
● Core part of a former Spring Cloud Netflix module, passed over to the community
● Supports various HTTP clients, including Apache HTTP, Apache HC5, Ok HTTP
● Contracts - support for custom annotations and argument resolution
● Support for a broad range of encoders/ decoders, including Jackson and GSON
● Metrics, including Micrometer support
16. Spring Cloud OpenFeign
Spring MVC and Spring Cloud support for OpenFeign
● Spring MVC annotations support
● Auto-configurations for Feign-specific beans
● Spring Cloud LoadBalancer support
● Spring Cloud CircuitBreaker support
● Tracing support
19. Spring Cloud OpenFeign Demo
Applications communicating over HTTP
Customer Service
SC OpenFeign Client
SC LoadBalancer
SC Sleuth
Verification Service
POST /verify
Customer Verification Result
Eureka Service Registry
20. Spring Cloud OpenFeign - popularity
Highly-readable interface clients with robust integrations
● 906 GitHub stars
● 8670549 Maven downloads in 2021
● Nearly flat learning curve for Spring MVC users
21. Spring Cloud OpenFeign - issues
● Issues with reusing client interfaces as controllers
○ @RequestMapping at class level user issues (GH-547, GH-678)
○ CVE-2021-22044
● Maintenance issues caused by dependence on third party upstream project
● Lack of non-blocking support
22. Spring Cloud Square
Spring Boot and Spring Cloud support for Retrofit and OkHttp
● WebClient support for Retrofit interface clients
● Auto-configurations
● Load-balancing
● Tracing
● Only Retrofit annotations
● Incubator project
50. Spring Interface Clients Demo
Applications communicating over HTTP
Customer Service
Spring HTTP Interface Client
SC LoadBalancer
Verification Service
POST /verify
Customer Verification Result
Eureka Service Registry