I have a simple case study:
I want to use Trident Storm to calculate the average temperature from multiple sensors. Kafka is used as the source and sink data. The data from one sensor looks like this:
{
"uuid": "e5778f99-d300-42cb-9992-cf453aa2d25f",
"sensor_uuid": "e5778f99-d400-42cb-9992-cf453272d25f",
"temp": "24.8"
}
Is there a way in Trident Storm to group events (by the field named sensor_uuid), then apply windowing, which allows calculation?
My current code:
this.topologyBuilder
.newStream("kafkaSpout", createKafkaTridentSpoutOpaque())
.tumblingWindow(12, new InMemoryWindowsStoreFactory(), new Fields("value"), new AggEvents(), new Fields("message"))
.partitionPersist(createTridentKafkaStateFactory(), new Fields("message"), new TridentKafkaStateUpdater<String, String>(), new Fields());
Unfortunately, I can't use groupBy()
before tumblingWindow()
because it returns GroupedStream, which doesn't support windowing.
How can I achieve my goal?