title: Spring Flux and the Async annotation
body: <p>I have a Spring Flux application where at some point I need to execute some heavy task on the background, the caller (a HTTP request) does not need to wait until that task completes.</p>
  
  <p>Without reactor, I would just probably use the <a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/annotation/Async.html" rel="noreferrer">Async</a> annotation, executing that method on a different thread. 
  With reactor, I am not sure if I should proceed with that approach or if there is already a built-in mechanism that allows me to accomplish this.</p>
  
  <p>For example, given a <em>Controller</em> that accepts a <em>Resource</em> object:</p>
  
  <pre class="lang-java prettyprint-override"><code>@PostMapping("/create")
  public Mono&lt;Resource&gt; create(@Valid @RequestBody Resource r) {
      processor.run(r); // the caller should not wait for the resource to be processed
      return repository.save(r);
  }
  </code></pre>
  
  <p>And a <em>Processor</em> class:</p>
  
  <pre><code>@Async
  void run(Resource r) { 
      WebClient webClient = WebClient.create("http://localhost:8080");
      Mono&lt;String&gt; result = webClient.get()
                                     .retrieve()
                                     .bodyToMono(String.class);
      String response = result.block(); //block for now
  }
  </code></pre>
  
  <p>The HTTP caller for <code>/create</code> should not need to wait until the <code>run</code> method completes.</p>