I need to basically write a lock for the current project I’m working on that when a connection has failed, all threads calling a given method should hang until the connection is reestablished.
How do I do this again in Java? It’s been a while since I’ve had to deal with this problem.
You could wait on a Condition inside the method. The condition would be something like:
There’s a lot more to it than this pseudo-code, of course.
You might want to read up on the so-called circuit breaker pattern too. Kind of a buzz-wordy thing, but it’s goal is to manage integration points that can fail, like your connection to the db.