Suppose I have a rest service
http://localhost:8080/test/api/check
And I want this service to be called once a day, but whoever calls it is the same application, is it possible?
NOTE: I can't use a cron
Suppose I have a rest service
http://localhost:8080/test/api/check
And I want this service to be called once a day, but whoever calls it is the same application, is it possible?
NOTE: I can't use a cron
If it's the same app, you can create a task using Quartz or directly using Spring:
For this to work you need to add the corresponding annotation to the Spring configuration:
or if the configuration goes through XML:
Particularly and from experience I would not call is to use some scheduler library in java. Above all, when doing this you must take special care not to make an http request. It is not necessary if you make a design to be able to call the same "command" from different endpoints. An example is worth a thousand words:
The rest endpoint, I haven't used Spring annotations because I don't know if you use it.
The creation of quartz, if you use Spring, you have it super easy with the instructions of @Pablo Lozano . As I have assumed that you do not use it, I will give you an example using Quartz Doc quartz . You must make a call to the init method when starting the application, since I do not have information about your system, I cannot give you details.
I've also assumed for simplicity that you don't need parameters.