Class SimpleSourceConnector

  • All Implemented Interfaces:
    org.apache.kafka.connect.components.Versioned

    public class SimpleSourceConnector
    extends org.apache.kafka.connect.source.SourceConnector
    A very simple SourceConnector for testing that reliably produces the same records in the same order, and useful for testing the infrastructure to run SourceConnectors.

    This connector produces messages with keys having a single monotonically-increasing integer field named id:

     {
         "id" : "1"
     }
     
    and values with a batch field containing the 1-based batch number, a record field containing the 1-based record number within the batch, and an optional timestamp field that contains a simulated number of milliseconds past epoch computed by adding the start time of the connector task with the message id:
     {
         "batch" : "1",
         "record" : "1",
         "timestamp" : null
     }
     
    Author:
    Randall Hauch
    • Constructor Detail

      • SimpleSourceConnector

        public SimpleSourceConnector()
    • Method Detail

      • version

        public String version()
      • start

        public void start​(Map<String,​String> props)
        Specified by:
        start in class org.apache.kafka.connect.connector.Connector
      • taskClass

        public Class<? extends org.apache.kafka.connect.connector.Task> taskClass()
        Specified by:
        taskClass in class org.apache.kafka.connect.connector.Connector
      • taskConfigs

        public List<Map<String,​String>> taskConfigs​(int maxTasks)
        Specified by:
        taskConfigs in class org.apache.kafka.connect.connector.Connector
      • stop

        public void stop()
        Specified by:
        stop in class org.apache.kafka.connect.connector.Connector
      • config

        public org.apache.kafka.common.config.ConfigDef config()
        Specified by:
        config in class org.apache.kafka.connect.connector.Connector