title: Record not persisted into R2DB using Spring boot webflux reactive
body: <p>I am trying to build an application using reactive. Initially i used to get proper response but after modifying the code, the record is not persisted into Database, but when I changed the logic to modify the response body, I see a success response but no record was found in DB nor I can see an error in logs.</p>
  <p><strong>Code before Modifying:</strong></p>
  <pre><code>public Mono&lt;ServerResponse&gt; createCustomer(ServerRequest serverRequest) {
          return serverRequest.bodyToMono(Customer.class).flatMap(customer -&gt; {
              ServerResponse.ok()
                  .contentType(MediaType.APPLICATION_JSON)
                  .body(customerRepository.save(customer), Customer.class);
  
          });
      }
  </code></pre>
  <p>But I want to return a generic API Response for all API calls and modified the code as below:</p>
  <pre><code>public Mono&lt;ServerResponse&gt; createCustomer(ServerRequest serverRequest) {
          Response response = new Response();
          return serverRequest.bodyToMono(Customer.class).flatMap(customer -&gt; {
              saveCustomer(customer,apiResponse);
              return ServerResponse.ok()
                  .contentType(MediaType.APPLICATION_JSON)
                  .body(Mono.just(apiResponse), Response.class);
  
          }).doOnError(err -&gt; {
                      log.error(&quot;Exception while creating customr record&quot;, err);
          }).onErrorResume(err -&gt;  {
              apiResponse.setError(new Error(err.getMessage(),err.getCause()));
              return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR)
                          .contentType(MediaType.APPLICATION_JSON)
                          .body(Mono.just(apiResponse), ApiResponse.class);
          });
      }
  
      public Response saveCustomer(Customer customer,Response apiResponse){
          customerRepository.save(customer);
          apiResponse.setCode(&quot;0&quot;);
          apiResponse.setMessage(&quot;Successfully Created customer&quot;);
          return apiResponse;
      }
  </code></pre>
  <p>Any thoughts are appreciated please.</p>