Print Kafka Topic Messages using KSQL

Print-kafka-topic-messages-using-KSQL

Confluent Platform is a full-scale Kafka data streaming managed cloud service that enables us to access, store and manage data as a continuous, real-time stream. This quick article describes how to Print Kafka topic messages using KSQL.

What is Confluent Cloud?

Confluent is a full-scale data streaming managed cloud service that enables us to access, store, and manage data as a continuous, real-time stream. Confluent Cloud provides ksqlDB, a streaming SQL engine for Kafka. It is an easy-to-use yet powerful interactive SQL interface for stream processing on Kafka,  In this article, we will see how to filter a Kafka stream by date using KSQL.

Print Kafka topic messages

Print all new messages from a topic.

PRINT 'name.of.the.topic'

Print a topic from the beginning

PRINT 'name.of.the.topic' from beginning;

Print the first 5 messages from a topic

PRINT 'name.of.the.topic' from beginning limit 5;

print every 100th message from the beginning, and stop after 5 messages.

PRINT  'name.of.the.topic' from beginning INTERVAL 100 limit 5;

Read more about it at ksql documentation.

Kunal Rathi

Been working in the data engineering and analytics space for over a decade. Helping customers transform their data into insights, Cloud & DevOps enthusiast.