title: How to use kotlin coroutines with reactive spring data
body: <p>I am trying to migrate some project from Spring Reactor to kotlin coroutines. I have some controller based on spring webflux like that:</p>
  
  <pre><code>@RestController
  class Controller(val productRepository: ProductsRepository) {
  
      @GetMapping("/product")
      fun find(@RequestParam id: String): Mono&lt;Product&gt; {
          return productRepository.findById(id)
      }
  }
  </code></pre>
  
  <p>This controller uses reactive spring data repository:</p>
  
  <pre><code>@Repository
  interface ProductsRepository : ReactiveMongoRepository&lt;Product, String&gt;
  </code></pre>
  
  <p>According to this official documentation - <a href="https://docs.spring.io/spring/docs/5.2.0.M1/spring-framework-reference/languages.html#how-reactive-translates-to-coroutines" rel="noreferrer">https://docs.spring.io/spring/docs/5.2.0.M1/spring-framework-reference/languages.html#how-reactive-translates-to-coroutines</a>, my function <code>find</code> in controller should be translated to <code>suspend fun</code> and this function should return an instance of Product class instead of reactive Mono wrapper of Product. Something like that:</p>
  
  <pre><code>@RestController
  class Controller(val productRepository: ProductsRepository) {
  
      @GetMapping("/product")
      suspend fun find(@RequestParam id: String): Product {
          return productRepository.findById(id)
      }
  }
  </code></pre>
  
  <p>But my productRepository deals with Mono and Flux, not suspended functions. How should I use spring data abstraction properly in that case?  </p>