đ¤Building a Telegram bot with Apache Kafka and ksqlDB
@rmoff
#NDCSydney
Robin Moffatt
Slide 2
Slide 3
Whereâs my nearest carpark with available spaces?
Slide 4
How many spaces are available in this car park?
Slide 5
đĄTell me when a car park with spaces is available
Slide 6
đHow does occupancy vary over time?
Slide 7
$ whoami > Robin Moffatt (@rmoff) > Senior Developer Advocate at Confluent (Apache Kafka, not Wikis đ) > Working in data & analytics since 2001 >
Oracle ACE Director (Alumnus)
http://rmoff.dev/talks ¡ http://rmoff.dev/blog ¡ http://rmoff.dev/youtube @rmoff
|
#NDCSydney
Slide 8
Slide 9
Telegram
@rmoff
|
#NDCSydney
Slide 10
Donât just tell meâŚ
show me!
Demo code: https://rmoff.dev/carparks
Slide 11
carparks
HTTP Kafka
@rmoff
|
#NDCSydney
Slide 12
What are the key pieces of the design? @rmoff
|
#NDCSydney
K/V Lookups (materialised views) SELECT SPACES_AVAILABLE How many spaces are free at â FROM CARPARK WHERE NAME=âWESTGATEâ; Westgate carpark right now? ksqlDB â Kafka
CARPARK_EVENTS
42 CREATE TABLE CARPARK AS SELECT LATEST(⌠GROUP BY NAME
â
There are 42 spaces free
@rmoff
|
â
#NDCSydney
My kingdom for a schema! 2020-10-14,12:28,Broadway,1132,921 2020-10-14,12:28,Kirkgate Centre,611,474 2020-10-14,12:28,Sharpe Street,98,63
đ
{ âtsâ: â2020-10-14T12:28 UTC+1â, ânameâ: âBroadwayâ, âcapacityâ: 1132, âemptyâ: 921 } âŚ
@rmoff
|
#NDCSydney
Slide 18
Applying a schema to streams of data source_topic
ksqlDB
CREATE STREAM mySource (date VARCHAR , time VARCHAR , name VARCHAR , capacity INT ) WITH (KAFKA_TOPIC=âsource_topicâ, VALUE_FORMAT=âDELIMITEDâ);
Kafka
@rmoff
|
#NDCSydney
Slide 19
Applying a schema to streams of data source_topic
ksqlDB
Kafka derived_topic
CREATE STREAM mySource (date VARCHAR , time VARCHAR , name VARCHAR , capacity INT ) WITH (KAFKA_TOPIC=âsource_topicâ, VALUE_FORMAT=âDELIMITEDâ); CREATE STREAM myTargetStream WITH (VALUE_FORMAT=âPROTOBUFâ, KAFKA_TOPIC=âderived_topicâ) AS SELECT * FROM mySource;
@rmoff
|
#NDCSydney
Stream Processing with ksqlDB
âŚSUM(TXN_AMT) GROUP BY AC_ID
AC
_I
D=
42
BA LA NC AC E= _I 94 D= .0 42 0
Source stream
Applications / Microservices @rmoff
|
#NDCSydney
Slide 44
Under the covers of ksqlDB @rmoff
|
#NDCSydney
Photo by
on
Slide 45
Kafka cluster consume
produce
ksqlDB
@rmoff
|
#NDCSydney
on Photo by
Want to learn more? CTAs, not CATs (sorry, not sorry)
@rmoff
|
#NDCSydney
Slide 58
Try it out for yourself https://rmoff.dev/carparks
Slide 59
60
DE
VA DV
$200 USD off your bill each calendar month for the first three months when you sign up https://rmoff.dev/ccloud Free money!
(additional $60 towards your bill đ )
Fully Managed Kafka as a Service * T&C: https://www.confluent.io/confluent-cloud-promo-disclaimer
Slide 60
Learn Kafka. Start building with Apache Kafka at Confluent Developer. developer.confluent.io
Slide 61
Confluent Community Slack group
cnfl.io/slack @rmoff
|
#NDCSydney
Slide 62
Further reading / watching
https://rmoff.dev/kafka-talks
@rmoff
|
#NDCSydney