Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Possible to switch from synchronous to asnchronous?

Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Posts: 527
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Maybe you could use a webs ocker?
Posts: 4868
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it were me I'd be looking more closely at why it is taking 10 minutes. Do you have an inefficient database query? Are you pulling back a lot of data you don't need?
Attractive, successful people love this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic