title: Kafka Streams group by and concatenation
body: <p>I have a Kafka stream that receives records and I want to concatenate messages based on particular field.</p>
  
  <p>A message in a stream looks like following:</p>
  
  <pre><code>Key: 2099
  Payload{
    email: tom@emample.com
    eventCode: 2099
  }
  </code></pre>
  
  <p>Expected Output:</p>
  
  <pre><code>key: 2099
  Payload{
      emails: tom@example, bill@acme.com, jane@example.com
  }
  </code></pre>
  
  <p>I can get the stream to run fine, I just am not sure what the lamda should contain.</p>
  
  <p>This is what I have done so far. I am not sure whether I should use map, aggregate or reduce or combination of those operations.</p>
  
  <pre><code>final StreamsBuilder builder = new StreamsBuilder();
  KStream&lt;String, Payload&gt; inputStream = builder.stream(INPUT_TOPIC);
  
  inputStream
          .groupByKey()
          .windowedBy(TimeWindows.of(TimeUnit.MINUTES.toMillis(300000)))
  
                                    // Not sure what to do here …..
  
  }).to (OUTPUT_TOPIC );
  </code></pre>