We are developing travel application for booking flight, bus tickets etc. For the flight tickets initially PNR (Passenger Name Record) will be generated, through that PNR confirmation of ticket will be done.
The problem is, if ticket is not confirmed with in 12 hours after generating the PNR, the PNR has to be canceled. If not, we will face penalty from Air GDS provider.
Up to now we have written Cron Schedulers which does this thing for every 15 minutes. We have problems by doing like this, and faced penalty also. I can’t run the schedulers every minute.
How can I cancel the PNR, after generating 12 hours if not booked.
aioobe provided some good references for solving this sort of problem. However if you want to solve the problem without having to worry about timers or other transient things that may disappear on you if the JVM ever needs to be shutdown and restarted, I’d suggest also considering a simple approach along the lines of:
Then, add to your server’s startup/initialization routine some code like:
Then your platform will automatically query for and delete any records that are older than 12 hours, at 30-second intervals.