Reputation: 57
I have a spring boot microservice which contains a method which I need to run every Sunday so I used @Scheduled annotation on the method and @EnableScheduling annotation in the configuration class.The method annotated with @Scheduling calls up a other method which in turn calls up a client class where response is fetched by making a rest call to a other microservice but the rest call step is not executing and it throws error when I use scheduled annotation when I trigger the method from controller it works fine but for scheduler the rest call is not happening.
Upvotes: 0
Views: 819
Reputation: 1044
Please share your code and the error you are getting. I am sharing an example for your reference.
@PostMapping(value = "/runWeeklyJob", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Scheduled(cron = "0 0 1 ? * SUN *")
public ResponseEntity<?> runWeeklyJob() throws Exception {
//processing
return responseEntity;
}
Upvotes: 1