title: How to send response before actions in spring mvc
body: <p>Say that my spring controller function receives a large amount of data.
  I want to return 200 OK, given that the data is structured right, and <strong>after that</strong> I want to perform the processing, which might take a while.</p>
  
  <p>To my understanding the only way to send response is by <strong>return</strong> command. But I don't want to end the function on response send. </p>
  
  <p>Are there other ways to send response to client at the middle of the function?</p>
  
  <p>Creating a new thread run is obvious but other languages (JS) let you handle it more elegantly.</p>
  
  <pre><code>@RequestMapping(value = Connectors.CONNECTOR_HEARTBEAT, method = RequestMethod.POST)
  public ResponseEntity&lt;String&gt; doSomething(@RequestBody List&lt;Message&gt; messages) {
      HttpStatus code = (messages!=null &amp;&amp; !messages.isEmpty()) ? HttpStatus.OK
              : HttpStatus.NOT_FOUND;
      return new ResponseEntity&lt;String&gt;(res, code);
     // how do I add code here??
  }
  </code></pre>