Class KafkaConsumerThread<T>

  • All Implemented Interfaces:
    Runnable

    @Internal
    public class KafkaConsumerThread<T>
    extends Thread
    The thread the runs the KafkaConsumer, connecting to the brokers and polling records. The thread pushes the data into a Handover to be picked up by the fetcher that will deserialize and emit the records.

    IMPORTANT: This thread must not be interrupted when attempting to shut it down. The Kafka consumer code was found to not always handle interrupts well, and to even deadlock in certain situations.

    Implementation Note: This code is written to be reusable in later versions of the KafkaConsumer. Because Kafka is not maintaining binary compatibility, we use a "call bridge" as an indirection to the KafkaConsumer calls that change signature.

    • Constructor Detail

      • KafkaConsumerThread

        public KafkaConsumerThread​(org.slf4j.Logger log,
                                   Handover handover,
                                   Properties kafkaProperties,
                                   ClosableBlockingQueue<KafkaTopicPartitionState<T,​org.apache.kafka.common.TopicPartition>> unassignedPartitionsQueue,
                                   String threadName,
                                   long pollTimeout,
                                   boolean useMetrics,
                                   org.apache.flink.metrics.MetricGroup consumerMetricGroup,
                                   org.apache.flink.metrics.MetricGroup subtaskMetricGroup)
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread
      • shutdown

        public void shutdown()
        Shuts this thread down, waking up the thread gracefully if blocked (without Thread.interrupt() calls).