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 ofRunner
used by this appCR
- type ofCleanUpRunner
used by this appO
- type of execution options to create runnerE
- type ofExecutableApp
used by this appCA
- type ofConfiguredApp
used 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:bootstrapServers
outputTopic
labeledOutputTopics
schemaRegistryUrl
kafkaConfig
startApplication(String[])
from your main.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
KafkaApplication.CleanableApp<CR extends CleanUpRunner>
Provides access to aCleanUpRunner
and closes the associatedExecutableApp
static final class
KafkaApplication.RunnableApp<R extends Runner>
Provides access to aRunner
and closes the associatedExecutableApp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clean()
Clean all resources associated with this applicationvoid
close()
abstract A
Create a new app that will be configured and executed according to this application.final KafkaApplication.CleanableApp<CR>
Create a newKafkaApplication.CleanableApp
abstract AC
createConfiguration
(T topics) Create configuration to configure appfinal CA
Create a newConfiguredApp
that will be executed according to this application.protected abstract CA
createConfiguredApp
(A app, AC configuration) Create a newConfiguredApp
that will be executed according to the given config.final E
Create a newExecutableApp
that will be executed according to the requested command.Create options for running the appfinal KafkaApplication.RunnableApp<R>
Create a newKafkaApplication.RunnableApp
abstract T
Topics used by appvoid
Called before starting the application, e.g., invokingrun()
void
Called before cleaning the application, i.e., invokingclean()
void
Called before running the application, i.e., invokingrun()
void
run()
Run the application.void
setBootstrapServers
(String bootstrapServers) void
setKafkaConfig
(Map<String, String> kafkaConfig) void
setLabeledOutputTopics
(Map<String, String> labeledOutputTopics) void
setOutputTopic
(String outputTopic) void
setSchemaRegistryUrl
(String schemaRegistryUrl) void
startApplication
(String[] args) This method should be called in the main method of your applicationint
startApplicationWithoutExit
(String[] args) This method should be called in the main method of your applicationfinal void
stop()
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:
close
in interfaceAutoCloseable
- See Also:
-
stop
public final void stop() -
run
public void run()Run the application. -
getRuntimeConfiguration
-
createExecutableApp
Create a newExecutableApp
that will be executed according to the requested command.- Returns:
ExecutableApp
-
createConfiguredApp
Create a newConfiguredApp
that 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 newConfiguredApp
that 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
-