I am calling an API to get the response, but if API is down, my request hangs there and control doesn't come back until the API is up. Once API is Up and Running all the requests that are hanged are flooded all at once to it and then we are getting the response.
My requirement is like this :
1.Call the API
2.Wait for 15 Seconds to get the response
3.If i don't get the response with in 15 seconds, do something(Example : throw an exception)
4.Close the connection that i had connected.
Please help with code snippet.
I have tried using CloseableHttpClient,HttpResponse,CloseableHttpResponse.