title: Kafka KStream OutOfOrderSequenceException
body: <p>Our application intermittently encounters OutOfOrderSequenceException in our streams code. Which causes stream thread to stop.</p>
  
  <p>Implementation is simple, 2 KStreams join and output to another topic.</p>
  
  <p>When searching for a solution to this OutOfOrderSequenceException
  I have found below documentation on Confluent </p>
  
  <p><a href="https://docs.confluent.io/current/streams/concepts.html#out-of-order-handling" rel="nofollow noreferrer">https://docs.confluent.io/current/streams/concepts.html#out-of-order-handling</a> </p>
  
  <p>But could not find what settings, config or trade-offs are being referred here ?
  How to manually do bookkeeping ?</p>
  
  <blockquote>
    <p>If users want to handle such out-of-order data, generally they need to
    allow their applications to wait for longer time while bookkeeping
    their states during the wait time, i.e. making trade-off decisions
    between latency, cost, and correctness. <strong><em>In Kafka Streams, users can
    configure their window operators for windowed aggregations to achieve
    such trade-offs (details can be found in the Developer Guide)</em></strong>.</p>
  </blockquote>