You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "David Hay (Jira)" <ji...@apache.org> on 2019/09/26 22:41:00 UTC

[jira] [Created] (KAFKA-8949) MockConsumer.assign and ConsumerRebalanceListener

David Hay created KAFKA-8949:
--------------------------------

             Summary: MockConsumer.assign and ConsumerRebalanceListener
                 Key: KAFKA-8949
                 URL: https://issues.apache.org/jira/browse/KAFKA-8949
             Project: Kafka
          Issue Type: Bug
            Reporter: David Hay


Using MockConsumer, one must either use {{assign}} or {{subscribe}}, not both.  However, if you decide to use the {{assign}} method, there is not an easy way to register a ConsumerPartitionListener that will get called when {{assign}} is called.  The current work around is to do the following:
{code:java}
MockConsumer consumer = new MockConsumer();
consumer.subscribe(Collections.singletonList("test.topic"), listener);
consumer.unsubscribe();
consumer.assign(Arrays.asList(new TopicPartition("test.topic", 1), ...)){code}
Would be nice to do something like:
{code:java}
MockConsumer consumer = new MockConsumer();
consumer.registerRebalanceListener();
consumer.assign(...){code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)