Skip to content

YavaConf 2022

This is the demo part of my talk about ksqlDB at Ya!vaConf conference in Warsaw Poland, 28 September 2022.

YavaConf 2022

Start Confluent Platform (No ksqlDB Yet)

./start-confluent.sh docker-compose.yml

CLI

SHOW TOPICS;
CREATE STREAM names (
  name STRING)
WITH (
  kafka_topic='names',
  partitions=1,
  value_format='kafka');
SELECT * FROM names;
SELECT * FROM names EMIT CHANGES;
INSERT INTO names VALUES ('yavaconf');
INSERT INTO names VALUES ('java');
$ echo yavaconf | kcat -P -b :9092 -t names
$ echo java | kcat -P -b :9092 -t names
SHOW FUNCTIONS;
DESCRIBE FUNCTION ucase;
SELECT UCASE(name) upper FROM names;
CREATE STREAM uppers AS
  SELECT UCASE(name) upper
  FROM names;
SHOW QUERIES;
EXPLAIN CSAS_UPPERS_7;

REST API

ksqlDB uses Eclipse Vert.x to handle HTTP communication using REST endpoints.

http -b localhost:8088/info
http -b localhost:8088/healthcheck
http -b localhost:8088/status
http -b http://localhost:8088/ksql ksql="LIST STREAMS;"

Queries File and Headless Execution Mode

You can execute all the above KSQL statements (incl. queries) using a queries file. The idea is to git-control it.

./bin/ksql -f yavaconf.ksql

You can also execute ksqlDB server in headless execution mode.

(Re)Start Confluent Platform

This time we're going to use the entire Confluent Platform (incl. ksqlDB).

./start-confluent.sh docker-compose.yml

Dockerized ksqlDB CLI for Queries File

docker run \
  --network=confluent-platform_default \
  -it \
  -v $(pwd):/home/appuser \
  confluentinc/cp-ksqldb-cli http://ksqldb-server:8088 \
  -f yavaconf.ksql