Class KafkaStreamsApplication

  • All Implemented Interfaces:
    java.lang.Runnable

    public abstract class KafkaStreamsApplication
    extends java.lang.Object
    implements java.lang.Runnable

    The base class of the entry point of the streaming application.

    This class provides common configuration options e.g. brokers, productive for streaming application. Hereby it automatically populates the passed in command line arguments with matching environment arguments EnvironmentArgumentsParser. To implement your streaming application inherit from this class and add your custom options.
    • Constructor Detail

      • KafkaStreamsApplication

        public KafkaStreamsApplication()
    • Method Detail

      • startApplication

        protected static void startApplication​(KafkaStreamsApplication app,
                                               java.lang.String[] args)

        This methods needs to be called in the executable custom application class inheriting from KafkaStreamsApplication.

        Parameters:
        app - An instance of the custom application class.
        args - Arguments passed in by the custom application class.
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • buildTopology

        public abstract void buildTopology​(org.apache.kafka.streams.StreamsBuilder builder)
      • createTopology

        public org.apache.kafka.streams.Topology createTopology()
      • getKafkaProperties

        public java.util.Properties getKafkaProperties()

        This method should give a default topic configuration to run your streaming application with.

        To add a custom configuration please add a similar method to your custom application class:
        
           public Properties getKafkaProperties() {
               # Try to always use the kafka properties from the super class as base Map
               Properties kafkaConfig = super.getKafkaProperties();
               kafkaConfig.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, GenericAvroSerde.class);
               kafkaConfig.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, GenericAvroSerde.class);
               return kafkaConfig;
           }
         
        Returns:
        Returns a default kafka configuration Properties