Service consumer

Let's set up another simple microservice to consume the random service exposed by Microservice A. Let's use Spring Initializr (https://start.spring.io) to initialize the microservice, as shown in the following screenshot:

Let's add the service to consume random service:

    @RestController    public class NumberAdderController {      private Log log = LogFactory.getLog(        NumberAdderController.class);      @Value("${number.service.url}")      private String numberServiceUrl;      @RequestMapping("/add")      public Long add() {        long sum = 0;        ResponseEntity<Integer[]> responseEntity =          new RestTemplate()          .getForEntity(numberServiceUrl, Integer[].class); Integer[] ...

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.