Good Fernando, as you said, seems to have the same purpose.
I have already had the opportunity to implement both models in Spring. What served me as a criterion for using one or the other was really the purpose.
Where I used the Feign
, and why did I use it?
As you may have noticed in your Feign implementation, it is very easy to create interfaces between your application and other services, specifying paths and methods very clearly via annotations. It is also facilitated the handling of error and other returns through the configuration of Decoders. So in situations I want to make a kind of "interface" between the application To and the application B going through an API of mine I use Feign.
Already the RestTemplate
, I usually adopt when I need to make a punctual call to an external service my application, considering that it has a simple implementation to do, without need of extra settings as can be seen in the example below.
RestTemplate restTemplate = new RestTemplate();
String fooResourceUrl
= "http://localhost:8080/spring-rest/foos";
ResponseEntity<String> response
= restTemplate.getForEntity(fooResourceUrl + "/1", String.class);
assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
A good documentation on the implementation of a Resttemplate can be seen here The Guide to Resttemplate.
I hope I’ve helped.
thanks for the clarification
– Fernando Guedes