title: Does the Kafka Streams StreamBuilder always detect "duplicate" input topics?
body: <p>This code creates two <code>KStream</code> instances <em>separately</em>, both are reading from the <em>same</em> topic:</p>
  <pre><code>    final KStream&lt;String, String&gt; inputStream1 =
        builder.stream(INPUT_TOPIC, consumed);
      final KStream&lt;String, String&gt; inputStream2 =
        builder.stream(INPUT_TOPIC, consumed);
  
      final KStream&lt;String, String&gt; mappedStream1 = inputStream1
              .peek((k, v) -&gt; System.out.println(&quot;1: &quot; + k + &quot; -&gt; &quot; + v))
              .mapValues((ValueMapper&lt;String, String&gt;) String::toLowerCase);
  
      final KStream&lt;String, String&gt; mappedStream2 = inputStream2
              .peek((k, v) -&gt; System.out.println(&quot;2: &quot; + k + &quot; -&gt; &quot; + v))
              .mapValues((ValueMapper&lt;String, String&gt;) String::toUpperCase);
  
      mappedStream1.to(OUTPUT_TOPIC_1, produced);
      mappedStream2.to(OUTPUT_TOPIC_2, produced);
  </code></pre>
  <p>The topology looks like this: There is only one <em>source</em> definition which is then used <em>two times</em>:</p>
  <pre><code>Topologies:
     Sub-topology: 0
      Source: KSTREAM-SOURCE-0000000000 (topics: [input])
        --&gt; KSTREAM-PEEK-0000000002, KSTREAM-PEEK-0000000004
      Processor: KSTREAM-PEEK-0000000002 (stores: [])
        --&gt; KSTREAM-MAPVALUES-0000000003
        &lt;-- KSTREAM-SOURCE-0000000000
      Processor: KSTREAM-PEEK-0000000004 (stores: [])
        --&gt; KSTREAM-MAPVALUES-0000000005
        &lt;-- KSTREAM-SOURCE-0000000000
      Processor: KSTREAM-MAPVALUES-0000000003 (stores: [])
        --&gt; KSTREAM-SINK-0000000006
        &lt;-- KSTREAM-PEEK-0000000002
      Processor: KSTREAM-MAPVALUES-0000000005 (stores: [])
        --&gt; KSTREAM-SINK-0000000007
        &lt;-- KSTREAM-PEEK-0000000004
      Sink: KSTREAM-SINK-0000000006 (topic: output-1)
        &lt;-- KSTREAM-MAPVALUES-0000000003
      Sink: KSTREAM-SINK-0000000007 (topic: output-2)
        &lt;-- KSTREAM-MAPVALUES-0000000005
  </code></pre>
  <p>Now my question is: Is it always safe to assume that the <code>StreamBuilder</code> creates only one source (= only one consumer for the same topic)?</p>
  <p>In other words: Is it always guaranteed that - given a topic with multiple partitions - <code>inputStream1</code> and <code>inputStream2</code> see the same records?</p>
  <p>Or is it better to rewrite it to something like this, to make it explicit:</p>
  <pre><code>    final KStream&lt;String, String&gt; inputStream =
        builder.stream(INPUT_TOPIC, consumed);
  
      final KStream&lt;String, String&gt; mappedStream1 = inputStream
              .peek((k, v) -&gt; System.out.println(&quot;1: &quot; + k + &quot; -&gt; &quot; + v))
              .mapValues((ValueMapper&lt;String, String&gt;) String::toLowerCase);
  
      final KStream&lt;String, String&gt; mappedStream2 = inputStream
              .peek((k, v) -&gt; System.out.println(&quot;2: &quot; + k + &quot; -&gt; &quot; + v))
              .mapValues((ValueMapper&lt;String, String&gt;) String::toUpperCase);
  </code></pre>
  <p><strong>Update</strong></p>
  <p>The 2nd version results in this topology:</p>
  <pre><code>Topologies:
     Sub-topology: 0
      Source: KSTREAM-SOURCE-0000000000 (topics: [input])
        --&gt; KSTREAM-PEEK-0000000001, KSTREAM-PEEK-0000000003
      Processor: KSTREAM-PEEK-0000000001 (stores: [])
        --&gt; KSTREAM-MAPVALUES-0000000002
        &lt;-- KSTREAM-SOURCE-0000000000
      Processor: KSTREAM-PEEK-0000000003 (stores: [])
        --&gt; KSTREAM-MAPVALUES-0000000004
        &lt;-- KSTREAM-SOURCE-0000000000
      Processor: KSTREAM-MAPVALUES-0000000002 (stores: [])
        --&gt; KSTREAM-SINK-0000000005
        &lt;-- KSTREAM-PEEK-0000000001
      Processor: KSTREAM-MAPVALUES-0000000004 (stores: [])
        --&gt; KSTREAM-SINK-0000000006
        &lt;-- KSTREAM-PEEK-0000000003
      Sink: KSTREAM-SINK-0000000005 (topic: output-1)
        &lt;-- KSTREAM-MAPVALUES-0000000002
      Sink: KSTREAM-SINK-0000000006 (topic: output-2)
        &lt;-- KSTREAM-MAPVALUES-0000000004
  </code></pre>