Class KafkaSource<OUT>

  • Type Parameters:
    OUT - the output type of the source.
    All Implemented Interfaces:
    Serializable, org.apache.flink.api.connector.source.Source<OUT,​KafkaPartitionSplit,​KafkaSourceEnumState>, org.apache.flink.api.connector.source.SourceReaderFactory<OUT,​KafkaPartitionSplit>, org.apache.flink.api.java.typeutils.ResultTypeQueryable<OUT>

    @PublicEvolving
    public class KafkaSource<OUT>
    extends Object
    implements org.apache.flink.api.connector.source.Source<OUT,​KafkaPartitionSplit,​KafkaSourceEnumState>, org.apache.flink.api.java.typeutils.ResultTypeQueryable<OUT>
    The Source implementation of Kafka. Please use a KafkaSourceBuilder to construct a KafkaSource. The following example shows how to create a KafkaSource emitting records of String type.
    
     KafkaSource<String> source = KafkaSource
         .<String>builder()
         .setBootstrapServers(KafkaSourceTestEnv.brokerConnectionStrings)
         .setGroupId("MyGroup")
         .setTopics(Arrays.asList(TOPIC1, TOPIC2))
         .setDeserializer(new TestingKafkaRecordDeserializationSchema())
         .setStartingOffsets(OffsetsInitializer.earliest())
         .build();
     

    KafkaSourceEnumerator only supports adding new splits and not removing splits in split discovery.

    See KafkaSourceBuilder for more details on how to configure this source.

    See Also:
    Serialized Form