title: How to get last offset for all topic partition?
body: <p>I need to get last offset for all topic partitions each N seconds (for cache purpose). What <code>API</code> should I use for that? I think, I need the most reliable and fast way.</p>
  
  <p>I know two approaches:</p>
  
  <p>1) <a href="https://stackoverflow.com/a/38448775/1756750">First one</a>:</p>
  
  <pre><code>//assign the topic
  consumer.assign();
  
  //seek to end of the topic
  consumer.seekToEnd();
  
  //the position is the latest offset
  consumer.position();
  </code></pre>
  
  <p>2) Second one:</p>
  
  <pre><code>consumer.endOffsets()
  </code></pre>