I have configured a service and client and deployed into PCF Cloud. I have also bind both apps to Service Registry. As I have bind services with Service Registry, I am trying to access service app in client using it's name configuredd in bootstrap.yml file. I am getting "No instances available for service-app" error.
Below are configurations I followed. Service:
@SpringBootApplication
@EnableDiscoveryClient
public class Application {}
application.properties:
spring.cloud.services.registrationMethod = route
security.basic.enabled=false
bootstrap.yml:
spring:
application:
name: service-app
and a small controller
@RestController
@RequestMapping(value = "/calculate")
public class CalculationService {
@RequestMapping(value = "/addition", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public int addition(@QueryParam("X") int X, @QueryParam("Y") int Y) {
return X + Y;
}
}
Client:
@SpringBootApplication
@EnableDiscoveryClient
public class Application {}
application.properties:
spring.cloud.services.registrationMethod = route
security.basic.enabled=false
bootstrap.yml
spring:
application:
name: compute-client
and a controller accessing service with it's name.
@Autowired
RestTemplate restTemplate;
@RequestMapping(value = "/addition/{X}/{Y}")
public int addition(@PathVariable int X, @PathVariable int Y) {
String uri = "https://service-app/calculate/addition?X=" + X + "&Y=" + Y;
return restTemplate.getForObject(uri, Integer.class);
}
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
Both these applications are pushed to PCF and bind to Service Registry. I can access service by it's route. When I try accessing client end point it is giving me error
{
"timestamp": 1524236514920,
"status": 500,
"error": "Internal Server Error",
"exception": "java.lang.IllegalStateException",
"message": "No instances available for service-app",
"path": "/calculate/addition/14/13"
}
What I am missing?