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.

Pro tips:
1. If you want to automate Confluent ksql deployments, you can refer to this post.
2. This post describes how to filter kafka stream by date.

Kunal Rathi

With over 13 years of experience in data engineering and analytics, I've assisted countless clients in gaining valuable insights from their data. As a dedicated supporter of Data, Cloud and DevOps, I'm excited to connect with individuals who share my passion for this field. If my work resonates with you, we can talk and collaborate.

Shopping Cart
Scroll to Top