Spring reactive web clients
This is a pretty new feature which was added in Spring Framework 5. It enables us to interact with HTTP services, using the reactive paradigm.
It is not a replacement for a RestTemplate provided by Spring, however, it is an addition to working with reactive applications. Do not worry, the RestTemplate is an excellent and tested implementation for interaction with HTTP services in traditional applications.
Also, the WebClient implementation supports the text/event-stream mime type which can enable us to consume server events.
Producing WebClient in a Spring Way
Before we start to call the Twitter APIs, we want to create an instance of WebClient in a Spring way. It means we are looking for a way to inject the instance, using the Dependency Injection Pattern.
To achieve this, we can use the @Configuration annotation and create a WebClient instance, using the @Bean annotation to declare the bean for the Spring container. Let's do that:
package springfive.twittergathering...