Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-2359

New consumer - partitions auto assigned only on poll

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 0.9.0.0
    • None
    • consumer
    • None

    Description

      In the new consumer I encountered unexpected behavior. After constructing KafkaConsumer instance with configured consumer rebalance callback handler, and subscribing to a topic with "consumer.subscribe(topic)", retrieving subscriptions would return empty set and callback handler would not get called (no partitions ever assigned or revoked), no matter how long instance was up.

      Then I found by inspecting KafkaConsumer code that partition assignment will only be triggered on first poll, since pollOnce has:

      // ensure we have partitions assigned if we expect to
      if (subscriptions.partitionsAutoAssigned())
          coordinator.ensurePartitionAssignment();
      

      I'm proposing to fix this by including same ensurePartitionAssignment fragment in KafkaConsumer.subscriptions accessor as well.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sslavic Stevo Slavić
            Votes:
            9 Vote for this issue
            Watchers:
            15 Start watching this issue

            Dates

              Created:
              Updated: