Hey I have this web application set up with spring and postgres. Assume my application allows a user to make some reservation by specifying a time. If he does not show up within half an hour from the specified time I want to cancel this reservation. So assume the table where I'm storing the reservations contains a column with values of the specified reservation time and a boolean flag that indicates whether the user has arrived or not.
I can think of two ways to handle this scenario. One would be to create a spring controller that can check the values from the reservation table and see if the difference between the current time and the specified time is greater than half an hour and if it is then cancel the reservation. The other way is to create some postgres function that can achieve the same.
I want somebody to help me here. How do I repeatedly call the above mentioned spring controller at every time interval of say 15 minutes? Or if writing a postgres function that reduces the workload of the application how do I do this?
Any help is appreciated. Thanks in advance.
You could annotate the method you wish to be called with
@Scheduled(fixedRate=900000), this is a spring annotation to call that method every 15 minutes.
Check out the documentation.