I am new to kafka streams and I would like to read a topic and write a part of it in a new topic using kafka streams api. My key is string and value is Avro Is there a documentation/example that I can use ?
Edit :
final StreamsBuilder builder = new StreamsBuilder();
final KStream<String, GenericRecord> inputStream = builder.stream("Test_CX_TEST_KAFKA_X");
final KStream<String, String> newStream = inputStream.mapValues(value -> value.get("ID").toString());
newStream.to("SUB_TOPIC",Produced.with(Serdes.String(),Serdes.String()));
final KafkaStreams streams = new KafkaStreams(builder.build(), streamsConfiguration);
streams.start();
In SUB_TOPIC I have :
Key: { "ID": "145" } Timestamp: Mar 14th, 2019 17:52:23.43 Offset: 12 Partition: 0
my Input topic :
{ "ID": "145", "TIMESTAMP": 1552585938545, "WEEK": "\u0000", "SOURCE": { "string": "TMP" }, "BODY": { "string": "{\"operation_type\":\"INSERT\",\"old\":{\"ROW_ID\":null,\"LAST_UPD\":null,\"DENOMINATION\":null,\"SIREN_SIRET\":null},\"new\":{\"ROW_ID\":\"170309-********\",\"LAST_UPD\":\"2019-03-14T17:52:18\",\"DENOMINATION\":\"1-******\",\"SIREN_SIRET\":null}}" }, "TYPE_ACTION": { "string": "INSERT" } }
How can I add other fields from Body in the new topic ? example :
{ "ID": "145", "TIMESTAMP": 1552585938545, "WEEK": "\u0000", "SOURCE": { "string": "TMP" }, "BODY": { "string": "{\"operation_type\":\"INSERT\",\"old\":{\"ROW_ID\":null,\"LAST_UPD\":null},\"new\":{\"ROW_ID\":\"170309-********\",\"LAST_UPD\":\"2019-03-14T17:52:18\"}}" }, "TYPE_ACTION": { "string": "INSERT" } }