title: How to check that KafkaConsumer still has assigned partitions without reading more data with poll()
body: <p>In my KafkaConsumer app I want to read a batch of messages with poll() and process them. But processing may fail. In this case I want to retry until I succeed but only retry if consumer still owns partitions. I don't want to constantly call poll() because I don't want to read more data. </p>
  
  <p>This is a code snippet: </p>
  
  <pre><code>consumer = new KafkaConsumer&lt;&gt;(consumerConfig);
  try {
      consumer.subscribe(config.topics() /** Callback does not work as I do not call poll in between */ );
      while (true) {
          ConsumerRecords&lt;byte[], Value&gt; values = consumer.poll(10000);
          while (/* I am still owner of partitions */) {
              try {
                  process(values);
              } catch (Exception e) {
                  log.error("I dont care, just retry while I own the partitions", e)
              }
          }
      }
  } catch (WakeupException e) {
      // shutting down
  } finally {
      consumer.close();
  } 
  </code></pre>