Reputation: 1
I have this method which input's a JSON payload. I want to create a K-table out of this payload, read the data out of it and print it.
So far, I am to create the KTable, but when I iterate over it, the control skips over it.
Please can anyone help me/guide me where am I going wrong or what I am I missing?
Thanks.
public void twilioKTable(JsonNode payloadJson) throws JsonProcessingException {
String payload = payloadJson.toString();
final StreamsBuilder builder = new StreamsBuilder();
final KTable<String, String> kTable = builder.table("testktable");
kTable.toStream().map((key, value) -> new KeyValue<>(key, value))
.foreach(new ForeachAction<String, String>() {
public void apply(String key, String value) {
System.out.println("From MAP " + key + ": Value " +
value);
}
});
}
Upvotes: 0
Views: 1166
Reputation: 348
You could also use .peek()
method in KStream
to print every key with value
Upvotes: 1