Package com.bakdata.common_kafka_streams
Class KafkaStreamsApplication
- java.lang.Object
-
- com.bakdata.common_kafka_streams.KafkaStreamsApplication
-
- All Implemented Interfaces:
java.lang.Runnable
public abstract class KafkaStreamsApplication extends java.lang.Object implements java.lang.RunnableThe base class of the entry point of the streaming application.
This class provides common configuration options e.g.brokers,productivefor streaming application. Hereby it automatically populates the passed in command line arguments with matching environment argumentsEnvironmentArgumentsParser. To implement your streaming application inherit from this class and add your custom options.
-
-
Constructor Summary
Constructors Constructor Description KafkaStreamsApplication()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidbuildTopology(org.apache.kafka.streams.StreamsBuilder builder)org.apache.kafka.streams.TopologycreateTopology()java.util.PropertiesgetKafkaProperties()This method should give a default topic configuration to run your streaming application with.voidrun()protected static voidstartApplication(KafkaStreamsApplication app, java.lang.String[] args)This methods needs to be called in the executable custom application class inheriting fromKafkaStreamsApplication.
-
-
-
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:
runin interfacejava.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
-
-