If I do a call to the autowired RestTemplate it works like a charm:
GET on http://localhost:18990/microservice2/ (service registry):
{
"_links": {
"hl:echo": { "href": "http://localhost:18989/microservice2/echo?echoMessage={echoMessage}", "templated": true },
"curies":
[ {
"href": "/microservice2/generated-docs/api-guide.html#resources-{rel}",
"name": "hl",
"templated": true
}
]
}
}
From micro service 1(calling micro service 2 using the RestTemplate):
@Autowired
private RestTemplate restTemplate;
URI targetUrl = UriComponentsBuilder.fromUriString("http://microservice2")
.path("/microservice2/echo")
.queryParam("echoMessage", "echoMessage")
.build()
.toUri();
EchoMessageResource response = restTemplate.getForObject(targetUrl, EchoMessageResource.class);
OK
Ribbon does use Eureka to get to the real server behind the scenes.
If I add a rel then it does NOT work. I get a 404.
FROM:
URI targetUrl = UriComponentsBuilder.fromUriString("http://microservice2")
.path("/microservice2/echo")
.queryParam("echoMessage", "echoMessage")
.build()
.toUri();
TO:
URI targetUrl = UriComponentsBuilder.fromUriString("http://microservice2")
.path("/microservice2/hl:echo")
.queryParam("echoMessage", "echoMessage")
.build()
.toUri();
EchoMessageResource response = restTemplate.getForObject(targetUrl, EchoMessageResource.class);
KO 404
What is the way to use a rel ? In my example hl:echo.
OK. As The Spring Hateoas Client side support documentation does not make any reference to Ribbon, I make the assumption that Spring Hateoas does not support Ribbon at all.