title: Why don't Kafka's seekToBeginning and seekToEnd work with assign?
body: <p>Say, I want to check the offset of the first and last message in Kafka for a particular partition. My idea was to use the <code>assign(…)</code> method along with the <code>seekToBeginning(…)</code> and <code>seekToEnd(…)</code>. Unfortunately, this doesn't work. </p>
  
  <p>If I set <code>AUTO_OFFSET_RESET_CONFIG</code> to <code>"latest"</code>, the <code>seekToBeginning(…)</code> has no effect; if I set it to <code>"earliest"</code>, <code>seekToEnd(…)</code> doesn't work. It seems that the only thing that matters for my consumer is <code>AUTO_OFFSET_RESET_CONFIG</code>.</p>
  
  <p>I've seen a similar topic but the problem dealt with the <code>subscribe()</code>, not with the <code>assign()</code> method. The proposed solution was to implement the <code>ConsumerRebalanceListner</code> and pass it as a parameter to the <code>subscribe()</code> method. Unfortunately, the <code>assign()</code> method has only one signature and can only take a list of topic partitions. </p>
  
  <p>The question is: Is it possible to use the <code>seekToBeginning()</code> or <code>seekToEnd()</code> with the <code>assign()</code> method. If yes, how? If no, why?</p>
  
  <p>A relevant fragment of my code:</p>
  
  <pre class="lang-java prettyprint-override"><code>KafkaConsumer&lt;String, ProtoMeasurement&gt; consumer = createConsumer();
  TopicPartition zeroP = new TopicPartition(TOPIC, 1);
  List&lt;TopicPartition&gt; partitions = Collections.singletonList(zeroP);
  
  consumer.assign(partitions);
  consumer.poll(Duration.ofSeconds(1));
  consumer.seekToBeginning(partitions);
  long currOffsetPos = consumer.position(zeroP);
  LOGGER.info("Current offset {}.", currOffsetPos);
  ConsumerRecords&lt;String, ProtoMeasurement&gt; records = consumer.poll(Duration.ofMillis(100));
  // ...
  </code></pre>
  
  <p>The logger prints the offset n, which is the biggest (latest) offset of the considered topic.</p>