Skip to content

ConsumerStrategy — Kafka Consumer Providers

ConsumerStrategy is the <> for <> that can <> given Kafka parameters.

[[contract]] [source, scala]

package org.apache.spark.sql.kafka010

sealed trait ConsumerStrategy { def createConsumer(kafkaParams: ju.Map[String, Object]): Consumer[Array[Byte], Array[Byte]] }

.ConsumerStrategy Contract [cols="1m,2",options="header",width="100%"] |=== | Property | Description

| createConsumer | [[createConsumer]] Creates a Kafka[Consumer] (of keys and values of type Array[Byte])

Used exclusively when KafkaOffsetReader is requested to creating a Kafka Consumer |===

[[implementations]] .ConsumerStrategies [cols="1,2",options="header",width="100%"] |=== | ConsumerStrategy | createConsumer

| AssignStrategy | [[AssignStrategy]] Uses ++[KafkaConsumer.assign(Collection partitions)]

| SubscribeStrategy | [[SubscribeStrategy]] Uses ++[KafkaConsumer.subscribe(Collection topics)]

| SubscribePatternStrategy a| [[SubscribePatternStrategy]] Uses ++[KafkaConsumer.subscribe(Pattern pattern, ConsumerRebalanceListener listener)] with NoOpConsumerRebalanceListener.

TIP: Refer to[java.util.regex.Pattern] for the format of supported topic subscription regex patterns. |===

NOTE: ConsumerStrategy is a Scala sealed trait which means that all the <> are in the same compilation unit (a single file).

Last update: 2020-11-08