title: Count messages from kafka topic all hour
body: <p>I would like to count messages coming from kakfa topic.</p>
  
  <p>For example I have this case class:</p>
  
  <pre><code>case class Message(timestamp: LocalDateTime)
  </code></pre>
  
  <p>I receive message of this class, and I would like to count how many message I have within in 1 hour. Let suppose message are ordered in this topic (timestamp corresponds to when the message enter in the topic).</p>
  
  <p>I would like to create a case class like this:</p>
  
  <pre><code>case class Counter(datetime: LocalDateTime, count: Int)
  </code></pre>
  
  <p>Let say I have 100 messages the first hour, then 150 I will have:</p>
  
  <pre><code>Counter("2018-05-17 00:00:00", 100)
  Counter("2018-05-17 00:01:00", 150)
  </code></pre>
  
  <p>Any idea on how to that ? For information I can't/don't want to use kafka-streams.</p>
  
  <p>Thanks!</p>
  
  <p>EDIT:</p>
  
  <p>My source is a kafka topic which I would like to use with the Consumer API. My sink is a postgresql table.</p>