I have a spring boot web app, RESTfult webservices implemented. One request could take few minutes to fetch the results and sometimes same request could take 10 mins or more which will result in browser time out if I decided to go with synchronous call in this scenario.
Is it possible to switch from synchronous to asynchronous on the fly?
I would believe NO because I've recently handled asynchronous requests using ActiveMQ which is a different model all together if we compare it with synchronous call.
But then how do we handle the scenario I explained above - where I'm not sure how long a request is going to take?
You can put an asyncresponse in the parameter of the controller method and use that. Problem is that even though the controller isnt blocked you can still time out on the client end. If it takes 10 minutes then you probably want to find another way to transfer the data. Even if it's asynchronous it will still take the same amount of time.