Skip to content


KsqlServerMain is the ksqlDB server.

KsqlServerMain can be started on command line using ksql-server-start shell script (that supports command-line options).

When launched, KsqlServerMain starts an Executable:

  1. StandaloneExecutor with queries file specified (for headless execution mode)
  2. KsqlRestApplication unless ksql.connect.worker.config configuration property is specified
  3. MultiExecutable with a ConnectExecutable and a KsqlRestApplication

Creating Instance

KsqlServerMain takes the following to be created:

KsqlServerMain is created when:

  • KsqlServerMain application is launched

Launching Application

main parses the command-line options and loads the required properties file (with the Java system properties applied overriding earlier values).

main creates and validates a KsqlConfig.

main configures QueryLogger (with the KsqlConfig).

main creates an Executable based on the following:

  1. Properties with the Java system properties applied
  2. queries file command-line option (if defined)
  3. ksql.server.install.dir configuration property from the properties file
  4. A new KsqlConfig with the config and system properties
  5. A new MetricCollectors

main creates a new KsqlServerMain (with the Executable) and starts it up.


main is paused when starting up the executable (using awaitTerminated) until notifyTerminated which happens as part of a Java Virtual Machine shutdown hook.

Creating Executable

Executable createExecutable(
  Map<String, String> properties,
  Optional<String> queriesFile,
  String installDir,
  KsqlConfig ksqlConfig,
  MetricCollectors metricCollectors)

With queries file specified, createExecutable returns a new StandaloneExecutor.

Otherwise, createExecutable creates a KsqlRestConfig (with the given properties) to build a KsqlRestApplication (with the KsqlRestConfig and the given MetricCollectors).

With no ksql.connect.worker.config configuration property specified, createExecutable returns the KsqlRestApplication. Otherwise, createExecutable creates a ConnectExecutable and returns a MultiExecutable (with the ConnectExecutable and the KsqlRestApplication).


void tryStartApp()

tryStartApp prints out the following INFO message to the logs:

Starting server

tryStartApp requests the Executable to startAsync.

tryStartApp prints out the following INFO message to the logs:

Server up and running

tryStartApp requests the Executable to awaitTerminated.

Finally (when the Executable was requested to terminate), tryStartApp prints out the following INFO message to the logs:

Server shutting down

tryStartApp requests the Executable to shutdown.