'Merging multiple messages into single message using Kafka streams

I am new to the kafka streams , I want to merge multiple messages into a single message from a topic.

Topic name : sample

 A :  {"id" : "123" , "name" : "abc" ,  "address" : [{"place": "a2" , "dno" : "1-1"}] }
 A :  {"id" : "123" , "name" : "abc" ,  "address" : [{"place": "a2" , "dno" : "1-2"}] }
 A  : {"id" : "123" , "name" : "abc" ,  "address" : [{"place": "a3" , "dno" : "1-3"}] }

I have to merge all this three into one message by using "Key" like below.

A :  {"id" : "123" , "name" : "abc" ,  "address" : [{"place": "a2" , "dno" : "1-1"},{"place": "a2" , "dno" : "1-2"},{"place": "a3" , "dno" : "1-3"}] }

Can anyone provide the way to merge these messages ( using Kafka Windowing / other)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source