We have a couple of microservices managed using AWS API Gateway which also acts as a load balancer. We have not integrated spring cloud and eureka services to perform load balancing and invoke external service calls.
Does it make sense to replace RestTemplate with feign-client only for not writing unit test cases?
2
Answers
Not sure how this is related to unit tests, but you can replace
RestTemplate
with Spring Cloud OpenFeign for a leaner, more readable API. It may also handle client-side load-balancing for you under the hood. However, you might wish to wait till Spring 6 release and switch to using the new Spring interface client instead.We can use feign client without using the eureka server and config client. Feign client sits on top of the rest template.
So for better intercommunication between two microservices feign client works fine.
All you need to do is to supply additional parameter for url to the feign client @FeignClient along with name param
The port needs to be a fixed port and cannot be randomized provided by spring boot. So user server port
application.yml