title: How to return a Flux in async/reactive webclient request with subscribe method
body: <p>I am using spring hexagonal architecture (port and adapter) as my application need to read the stream of data from the source topic, process/transforms the data, and send it to destination topic.</p>
  <p>My application need to do the following actions.</p>
  <ol>
  <li>Read the data (which will have the call back url)</li>
  <li>Make an http call with the url in the incoming data (using webclient)</li>
  <li>Get the a actual data and it needs to be transformed into another format.</li>
  <li>Send the transformed data to the outgoing topic.</li>
  </ol>
  <p>Here is my code,</p>
  <pre><code>public Flux&lt;TargeData&gt; getData(Flux&lt;Message&lt;EventInput&gt;&gt; message) 
  {
      return message
          .flatMap(it -&gt; {
              Event event = objectMapper.convertValue(it.getPayload(), Event.class);
              String eventType = event.getHeader().getEventType();
              String callBackURL = &quot;&quot;;
              if (DISTRIBUTOR.equals(eventType)) {
                  callBackURL = event.getHeader().getCallbackEnpoint();
                  WebClient client = WebClient.create();
                  Flux&lt;NodeInput&gt; nodeInputFlux = client.get()
                      .uri(callBackURL)
                      .headers(httpHeaders -&gt; {
                          httpHeaders.setContentType(MediaType.APPLICATION_JSON);
                          List&lt;MediaType&gt; acceptTypes = new ArrayList&lt;&gt;();
                          acceptTypes.add(MediaType.APPLICATION_JSON);
                          httpHeaders.setAccept(acceptTypes);
                      })
                  .exchangeToFlux(response -&gt; {
                      if (response.statusCode()
                              .equals(HttpStatus.OK)) {
                          System.out.println(&quot;Response is OK&quot;);
                          return response.bodyToFlux(NodeInput.class);
                      }
                      return Flux.empty();
                  });
                  nodeInputFlux.subscribe( nodeInput -&gt; {
                      SourceData source = objectMapper.convertValue(nodeInput, SourceData.class);
                  //  return Flux.fromIterable(this.TransformImpl.transform(source));
                  });
              }
          return Flux.empty();
      });
  }
  </code></pre>
  <p>The commented line in the above code is giving the compilation as subscribe method does not allow return types.</p>
  <p>I need a solution &quot;without using block&quot; here.</p>
  <p>Please help me here, Thanks in advance.</p>