I am using Spring Download to create a RESTful web service . My IDE is Eclipse Oxygen.
I send several HTTP requests every 2 seconds via Chrome , but they are triggered one by one . Each request will wait for the completion of the previous request.
Here is my controller code:
@RestController @RequestMapping("/dummy") public class DummyController { @RequestMapping(method = RequestMethod.GET) public ResponseEntity<Map<String, String>> dummytsp(@RequestParam(value="msg", defaultValue="Hello") String msg) { System.out.println("" + new Date() + ": ThreadId " + Thread.currentThread().getId()); try { Thread.sleep(5000); } catch (InterruptedException e) {
My console console:
Thu Sep 14 11:31:15 EDT 2017: ThreadId 25 Thu Sep 14 11:31:20 EDT 2017: ThreadId 26 Thu Sep 14 11:31:25 EDT 2017: ThreadId 28 Thu Sep 14 11:31:30 EDT 2017: ThreadId 30
The console output indicates that the controller is called every 5 seconds . But I send requests every 2 seconds .
How can I handle multiple incoming requests at the same time? (I should see console output every 2 seconds)
UPDATE
If I send requests in different browsers, it works fine. If I test it in the same browser / application that shares the session, a problem will occur.
Is it possible to accept simultaneous multiple requests from the same session ?
Thanks!
source share