Skip to content

Instantly share code, notes, and snippets.

@moleike
Last active November 17, 2022 13:14
Show Gist options
  • Save moleike/45b1b1acb1ba1e066564c791e2eba6bb to your computer and use it in GitHub Desktop.
Save moleike/45b1b1acb1ba1e066564c791e2eba6bb to your computer and use it in GitHub Desktop.

kafka-workshop

Welcome to the kafka workshop @LINE Taiwan!

Goals

Today session will help you get started with doing some basic stream processing using Kafka Streams and KSQL, and how you can manage materialzed views using Kafka Connect.

In what follows, we will give you a detail step-by-step guide on building your first stream processing application. The application considers 2 data sources:

  • a Kafka topic with stores
  • a Kafka topic with photos (contain a reference to the store they belong to, i.e. foreign key)

The streaming app's task is to join the stores with the photos, and output a new topic with an enriched store, that contains stores with their photos.

The output topic will then be persisted via Kafka Connect to:

  • MySQL
  • Elasticsearch

Why is this streaming?

Every time a store or photo record is added to the topics, the output stream will be updated, and consequently the databases will reflect this changes.

There are 2 versions:

  • KSQL version (declarative-style)
  • Kafka Streams DSL version using Kotlin (functional-style)

You can work on either one, but we strongly recommed trying both.

To learn more about reorienting your database architecture around streams and materialized views, we recommend you to watch this Martin Kleppman talk (transcript):

Requirements

  • Docker
  • Gradle (for the Kotlin part)

Running the Confluent Platform

The docker-compose.yml file contains:

  • zookeeper
  • broker
  • schema-registry
  • connect
  • ksql-server
  • ksql-cli
  • elasticsearch
  • kibana
  • mysql
  • adminer

Apart from Kafka components, we also include Elasticsearch, Kibana and MySQL and Adminer.

Start all the services by running:

> docker-compose up

Connect to the KSQL Server

> docker exec -it ksql-cli ksql http://ksql-server:8088
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment