title: Zip Three Different Mono of Different Type
body: <p>I have started a new project using Spring Webflux and I am fairly new to this reactive coding paradigm. So apologies in advance for questioning like newbies.</p>
  
  <p>My controller method returns the response as <code>Mono&lt;ResponseEntity&lt;String&gt;&gt;</code> and I have three different services to call from where I am getting three different <code>Mono</code> object like this - </p>
  
  <pre><code>Mono&lt;CustomObject&gt; customMono = serivce1.method();
  Mono&lt;Boolean&gt; booleanMono = service2.method();
  Mono&lt;String&gt; stringMono = service3.method();
  </code></pre>
  
  <p>So in order prepare the response(<code>Mono&lt;ResponseEntity&lt;String&gt;&gt;</code>), I need to do something like this - </p>
  
  <pre><code>Mono.zip(customMono, booleanMono, stringMono, (customData, booleanData, stringData) -&gt; {
  ------
  return Mono.just(ResponseEntity.ok().body("-----"));
  });
  </code></pre>
  
  <p>The problem is, there are no such <code>zip</code> method to take 3 <code>Mono</code> and a function as parameters. I already found thise -
  <a href="https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#zip-reactor.core.publisher.Mono-reactor.core.publisher.Mono-java.util.function.BiFunction-" rel="noreferrer">https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#zip-reactor.core.publisher.Mono-reactor.core.publisher.Mono-java.util.function.BiFunction-</a></p>
  
  <p>but it doesn't fulfil my requirement. So issues I am facing</p>
  
  <ul>
  <li>I can not use <em>Mono.mergeWith</em> or <em>Mono.concaWith</em> method because my Mono object are of different kind.</li>
  <li>I can flatMap/map every Mono and create a chain. But I want service2 to be called parallel in a separate thread as it is not dependent on service1 call. But service3 call is dependent on service1 response.</li>
  </ul>
  
  <p>In summary, what I need to do:</p>
  
  <ul>
  <li>make service1 call at first</li>
  <li>make service2 call separately on different thread</li>
  <li>make service3 call which is dependent on service1 call data</li>
  <li>generating the final response object (<code>Mono&lt;ResponseEntity&lt;String&gt;&gt;</code>) using the data from all the service call.</li>
  </ul>
  
  <p>Thanks in advance. As a newbie, any suggestion is appreciated.</p>