[
https://issues.apache.org/jira/browse/KAFKA-8949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David Hay updated KAFKA-8949:
-----------------------------
Description:
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. Doing the following prevents the error message, but the listener still
isn't fired:
{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}
was:
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}
> MockConsumer.assign and ConsumerRebalanceListener
> -------------------------------------------------
>
> Key: KAFKA-8949
> URL: https://issues.apache.org/jira/browse/KAFKA-8949
> Project: Kafka
> Issue Type: Bug
> Reporter: David Hay
> Priority: Major
>
> 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. Doing the following prevents the error message, but
> the listener still isn't fired:
> {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)