Request an address, if it fails, it will be requested once every 30 seconds until it fails 10 times, then it will not be used. How to implement it?

  java, question

At present, the thinking method is that the database records the requested information (including the address of the request, the number of errors, and whether the request was successful) and then uses quartz to filter the unsuccessful callbacks of the database every 30 seconds to execute the callbacks. But I feel that it would be a waste to keep running on a regular task.

I want to know if there is a better solution.

This request failed. you need to determine the url http code.