title: Kafka Streams : Flushing intermediate Windowed results as commit interval and window time are not in sync
body: <p>Configuration for kafka Streams:</p>
  <pre><code>threads = 1;
  replicationFactor = 1;
  ktableCommitInterval= 10000;
  ktableMemory=72000000;
  timeDuration=10;
  </code></pre>
  <p>Topology:</p>
  <pre><code>KStream&lt;Windowed&lt;String&gt;,String&gt; windowedStringKStream =
                           streamsBuilder.stream(inputTopic, Consumed.with(Serdes.String(),Serdes.String()))
  .groupByKey(Grouped.with(Serdes.String(),Serdes.String()))
  .windowedBy(TimeWindows.of(Duration.ofSeconds(timeDuration)).grace(Duration.ofSeconds(0)))
                          .reduce(Numners::append,Materialized.&lt;String, String, WindowStore&lt;Bytes,byte[]&gt;&gt;as(storeName).withCachingEnabled().withRetention(Duration.ofSeconds(timeDuration)).withKeySerde(Serdes.String()).withValueSerde(Serdes.String()))
  .toStream();
         
   
  </code></pre>
  <p>Code Description:</p>
  <pre><code>Code appends numbers in a 10 Second window. Incremental Number records are sent exactly at a interval of 1 second into input topic.
  </code></pre>
  <p>Output:
  <a href="https://i.stack.imgur.com/W47ZW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W47ZW.png" alt="Output topic results with timestamp from kafka tool. As we can see every alternate output is a intermediate window result" /></a></p>
  <p>Problem:</p>
  <p>Commit interval is set to 10 seconds. Cache size is set to 72 mb. Data is in bytes. State store has caching enabled. Documentation states that the operating semantics of kafka streams pushing data to downstream is dependent on cache size or commit interval whatever happens first. But as per the experiments, commit is happening two times in a minute. The observation is Commit interval is starting when application starts but windowing starts when data starts coming. As seen in the image, intermediate window results are pushed and final window results are also pushed.</p>
  <p>Using Suppress() is not possible for the usecase i am working on as it will not flush the data if there is no new data coming on the topic.</p>
  <p>Any help would be appreciated. If somebody is facing this or wants to reproduce this let me know.</p>