Open sarmancoder opened 3 years ago
The code I use to monitor the services is that
@Scheduled(fixedDelay = 900000)
public List<String> listServices() throws TelegramApiException {
List<String> servicesActive = client.discoveryClient.getServices();
for (String service : services) {
if (!servicesActive.contains(service)) {
System.out.println("El servicio " + service + " esta caido");
SendMessage message = new SendMessage();
message.setChatId("-12343123446");
message.setText("El servicio " + service + " esta caido");
bot.execute(message);
}
}
return servicesActive;
}
I'm not sure how we can help, getServices()
is not a method from Eureka, if this is a SBN thing I suggest asking there. But honestly the use case and the problem is unclear anyway, if you could provide a minimal example with expected vs actual data I could at least point you in the right direction.
The problem is:
I am trying to use eureka so I can be sure all the services are running, for this, I use the getservices method Theoretically I should see in the step 2 my service I recent runned, but I see nothing, only after entering in the dashboard, next, in the getServices output I see my service listed
This problem can be fixed with the rest operations (I think) but I get a 404 when I make a request to /eureka/v2/apps
, therefore I asked this here, I don't know why I am getting 404 code
Any help please?
You may not be getting all the expected services because of a race?
Regarding the RESTful endpoint, it's GET /eureka/v2/apps
by default, so that's correct, I can't say why you're getting a 404 without knowing how you setup your server.
public @Bean FilterRegistrationBean<?> corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("http://localhost:4200");
config.addAllowedMethod("*");
config.addAllowedHeader("Accept");
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean<Filter> bean = new FilterRegistrationBean<Filter>(new CorsFilter(source));
bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
return bean;
}
Full example: https://github.com/EffNox/spring_eureka-rest-operations-angular
You may not be getting all the expected services because of a race?
Regarding the RESTful endpoint, it's
GET /eureka/v2/apps
by default, so that's correct, I can't say why you're getting a 404 without knowing how you setup your server.
On previous versions of eureka (probably somewhere around 2019) v2
does not exist - the path only works without it ... GET /eureka/apps
in this case .. i dont know why this API-breaking change (thats a big no-no!) was implemented but ... there you go.
Hi all, how it's going?
I am on the development of a monitoring services status based on spring. I developed a scheduled method so with getServices retrieves all the services are in the network, and look if som service is missing
The problem is that when I run a service that is registered in Eureka, and when I retrieve all the services I don't see the service I runned before, but if I enter the to de dashboard and next time I run getServices (from EurekaDiscoveryClient) I get the service I runned before
Thanks in advance