Bootiful ksqlDb part 2 --- creating a stream
In this post I will explore the ksqlDb API for creating streams. This is the second post about using ksqlDb with Spring Boot. Read the first post here. A stream in ksqlDb is analogous to a stream in Kafka Streams. One difference is how you create the stream. As described in the first post, a stream in Kafka Streams is created programmatically with an API. StreamsBuilder streamsBuilder = new StreamsBuilder(); KStream<Integer, Order> ordersStream = streamsBuilder.stream("orders"); ordersStream .filter((key, value) -> value.orderType == Electronics) .groupByKey() .aggregate(() -> 0.0f, (key, value, sum) -> sum += value.orderAmount) .toStream() .to("output"); Topology topology = streamsBuilder.build(); KafkaStreams kafkaStreams = new KafkaStreams(topology, new Properties()); kafkaStreams.start(); ksqlDb uplevels this to a more familiar SQL syntax. Here’s an example from the ksqlDb quickstart. ...