3

I have wrote spring rest Async controller, that return String JSON response, When I request the browser complete the response, while the controller have not completed the processing hence the response is not ready.

I am using Spring Boot, Apache as inbuilt server. In EmbeddedServletContainerFactory I have set AsyncTimeout too.

TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
        factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
            @Override
            public void customize(Connector connector) {
                connector.setAsyncTimeout(10000000);
            }
        });

so How I make the browser wait while the controller Async'ly complete the response?

And the controller is

@Async
 @RequestMapping(value = "/id", method = RequestMethod.GET)
    public String getDetails(@PathVariable("id") String id) {
       // wrote logic for JSON response....
}
Sanjay Rabari
  • 2,091
  • 1
  • 17
  • 32
  • Post your controller... – M. Deinum Jul 22 '15 at 06:43
  • @M.Deinum I have added controller in question – Sanjay Rabari Jul 22 '15 at 06:50
  • That is not the way to create an async controller. It will spawn a new thread and immediately return. See http://stackoverflow.com/questions/17167020/when-to-use-spring-async-vs-callable-controller-async-controller-servlet-3 for an explanation. Basically return `Callable` instead of making the method `@Async`. – M. Deinum Jul 22 '15 at 07:00

0 Answers0