https://github.com/jeffgbutler/microservice-workshop-java/
https://jeffgbutler.github.io/microservice-workshop-java/
@EnableFeignClients
annotation on a configuration class
@FeignClient(name="movie-award-service", url="http://localhost:8080")
public interface MovieAwardService {
@GetMapping("/award/search")
List<MovieAward> findAwardsForMovie(@RequestParam("movieId") Integer movieId);
}
This will call a web service with a URL like http://localhost:8080/award/search?movieId=3
Returned JSON will be automatically unmarshalled to the class you define
@FeignClient(name="movie-service", decode404=true, url="http://localhost:8080")
public interface MovieService {
@GetMapping("/movie/{id}")
Optional<Movie> findById(@PathVariable("id") Integer id);
}
With decode404=true
the code will return an empty
Optional if there is a 404 (NOT_FOUND) error
@FeignClient
are automatically discovered and available in the Spring
container@RestController
@FeignClient
Create Feign clients in the aggregate web service