Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read data from KSQL tables

maybe this is a beginner question but what is the recommended way to read data produced in KSQL?

Let's assume I do some stream processing and write the data to a KSQL table. Now I want to access this data via a Spring application (e.g. fan-out some live data via a websocket). My first guess here was to use Spring Kafka and just subscribe to the underlying topic. Or should I use Kafka Streams?

Another use-case could be to do stream processing and write the results to a Redis store (e.g. for a webservice which always returns current values). What would be the approach here?

Thanks!

like image 303
DerM Avatar asked Dec 27 '17 22:12

DerM


People also ask

Can we query data from Kafka?

When navigating to a Kafka topic, you can query all existing data and the live stream. Lenses immediately presents a snapshot of the latest data in table browsing mode allowing: To Filter by timestamp, offset or partition. To Drill into the data and expand the key and value payloads and any nested fields.

Is KSQL a database?

ksqlDB can be described as a real-time event-streaming database built on top of Apache Kafka and Kafka Streams. It combines powerful stream processing with a relational database model using SQL syntax.

What is KSQL table?

In KSQL, you create tables from Apache Kafka® topics, and you create tables of query results from other tables or streams. Use the CREATE TABLE statement to create a table from a Kafka topic. Use the CREATE TABLE AS SELECT statement to create a table with query results from an existing table or stream.


1 Answers

The results if KSQL queries are stored in Kafka topics. So you can access the results from third party applications by reading from the result topic. If the query result is a Table the resulted Kafka topic is a changelog topic meaning that you can read it into a table in third party system such as Cassandra or Redis. This table will always have the latest result and you can query it from web services. Check out our Clickstream demo where we push the results into Elastic for visualization. The visualized values are the latest values for in the corresponding tables.

https://github.com/confluentinc/ksql/tree/master/ksql-clickstream-demo#clickstream-analysis

like image 134
Hojjat Avatar answered Oct 06 '22 00:10

Hojjat