×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Davide Davide
Added: Dec 27, 2021 5:01 PM
Modified: Dec 27, 2021 5:04 PM
Views: 596
  1.  StreamJoined<String, Long, BodyTemp> joinParams =
  2.         // specify the Serdes to be used in the join
  3.         StreamJoined.with(Serdes.String(), Serdes.Long(), JsonSerdes.BodyTemp());
  4.  
  5.     JoinWindows joinWindows =
  6.         JoinWindows
  7.             // timestamps must be 1 minute apart
  8.             .of(Duration.ofSeconds(60))
  9.             // tolerate late arriving data for up to 10 seconds
  10.             .grace(Duration.ofSeconds(10));
  11.  
  12.     ValueJoiner<Long, BodyTemp, CombinedVitals> valueJoiner =
  13.         // Combine the heart rate and body temp into a CombinedVitals object.
  14.         (pulseRate, bodyTemp) -> new CombinedVitals(pulseRate.intValue(), bodyTemp);
  15.  
  16.     KStream<String, CombinedVitals> vitalsJoined =
  17.         // Perform the join.
  18.         highPulse.join(highTemp, valueJoiner, joinWindows, joinParams);