Package com.bakdata.kafka
Class KafkaApplication<R extends Runner,CR extends CleanUpRunner,O,E extends ExecutableApp<R,CR,O>,CA extends ConfiguredApp<E>,T,A,AC>
java.lang.Object
com.bakdata.kafka.KafkaApplication<R,CR,O,E,CA,T,A,AC>
- Type Parameters:
R- type ofRunnerused by this appCR- type ofCleanUpRunnerused by this appO- type of execution options to create runnerE- type ofExecutableAppused by this appCA- type ofConfiguredAppused by this appT- type of topic config used by this appA- type of appAC- type of configuration used by this app
- All Implemented Interfaces:
AutoCloseable,Runnable
- Direct Known Subclasses:
KafkaProducerApplication,KafkaStreamsApplication
public abstract class KafkaApplication<R extends Runner,CR extends CleanUpRunner,O,E extends ExecutableApp<R,CR,O>,CA extends ConfiguredApp<E>,T,A,AC>
extends Object
implements Runnable, AutoCloseable
The base class for creating Kafka applications.
This class provides the following configuration options:bootstrapServersoutputTopiclabeledOutputTopicsschemaRegistryUrlkafkaConfig
startApplication(String[]) from your main.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classKafkaApplication.CleanableApp<CR extends CleanUpRunner>Provides access to aCleanUpRunnerand closes the associatedExecutableAppstatic final classKafkaApplication.RunnableApp<R extends Runner>Provides access to aRunnerand closes the associatedExecutableApp -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclean()Clean all resources associated with this applicationvoidclose()abstract ACreate a new app that will be configured and executed according to this application.final KafkaApplication.CleanableApp<CR>Create a newKafkaApplication.CleanableAppabstract ACcreateConfiguration(T topics) Create configuration to configure appfinal CACreate a newConfiguredAppthat will be executed according to this application.protected abstract CAcreateConfiguredApp(A app, AC configuration) Create a newConfiguredAppthat will be executed according to the given config.final ECreate a newExecutableAppthat will be executed according to the requested command.Create options for running the appfinal KafkaApplication.RunnableApp<R>Create a newKafkaApplication.RunnableAppabstract TTopics used by appvoidCalled before starting the application, e.g., invokingrun()voidCalled before cleaning the application, i.e., invokingclean()voidCalled before running the application, i.e., invokingrun()voidrun()Run the application.voidsetBootstrapServers(String bootstrapServers) voidsetKafkaConfig(Map<String, String> kafkaConfig) voidsetLabeledOutputTopics(Map<String, String> labeledOutputTopics) voidsetOutputTopic(String outputTopic) voidsetSchemaRegistryUrl(String schemaRegistryUrl) voidstartApplication(String[] args) This method should be called in the main method of your applicationintstartApplicationWithoutExit(String[] args) This method should be called in the main method of your applicationfinal voidstop()toString()
-
Constructor Details
-
KafkaApplication
public KafkaApplication()
-
-
Method Details
-
startApplication
This method should be called in the main method of your application
This method calls System exit
- Parameters:
args- Arguments passed in by the custom application class.- See Also:
-
startApplicationWithoutExit
This method should be called in the main method of your application
- Parameters:
args- Arguments passed in by the custom application class.- Returns:
- Exit code of application
-
createExecutionOptions
Create options for running the app- Returns:
- run options if available
- See Also:
-
createTopicConfig
Topics used by app- Returns:
- topic configuration
-
createApp
Create a new app that will be configured and executed according to this application.- Returns:
- app
-
clean
public void clean()Clean all resources associated with this application -
close
public void close()- Specified by:
closein interfaceAutoCloseable- See Also:
-
stop
public final void stop() -
run
public void run()Run the application. -
getRuntimeConfiguration
-
createExecutableApp
Create a newExecutableAppthat will be executed according to the requested command.- Returns:
ExecutableApp
-
createConfiguredApp
Create a newConfiguredAppthat will be executed according to this application.- Returns:
ConfiguredApp
-
createConfiguration
Create configuration to configure app- Parameters:
topics- topic configuration- Returns:
- configuration
-
createRunnableApp
Create a newKafkaApplication.RunnableApp- Returns:
KafkaApplication.RunnableApp
-
createCleanableApp
Create a newKafkaApplication.CleanableApp- Returns:
KafkaApplication.CleanableApp
-
onApplicationStart
public void onApplicationStart()Called before starting the application, e.g., invokingrun() -
prepareRun
public void prepareRun()Called before running the application, i.e., invokingrun() -
prepareClean
public void prepareClean()Called before cleaning the application, i.e., invokingclean() -
createConfiguredApp
Create a newConfiguredAppthat will be executed according to the given config.- Parameters:
app- app to configure.configuration- configuration for app- Returns:
ConfiguredApp
-
toString
-
getOutputTopic
-
getLabeledOutputTopics
-
getBootstrapServers
-
getSchemaRegistryUrl
-
getKafkaConfig
-
setOutputTopic
-
setLabeledOutputTopics
-
setBootstrapServers
-
setSchemaRegistryUrl
-
setKafkaConfig
-