'How to call a method of Service(Svc1) in namespace A using RestTemplate in Service(Svc2) in Namespace B?

In Kubernetes environment with Java Spring applications deployed, I have 2 namespaces - Namespace A and Namespace B:

  • Namespace A has Service Svc1 with Method a
  • Namespace B has Service Svc2 with Method b

Both Services Svc1 and Svc2 are registered under Eureka server in Namespace B.

How to make a call from Method b in Service Svc2 to Method a in Service Svc1 using RestTemplate methods of Spring Framework?

exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType)

What will be the url that needs to be passed?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source