"Hello World" for Apache Kafka

First, install the WarpStream Agent for your platform.

Running the WarpStream Agent

warpstream playground

The playground command will start an Agent on localhost, store all the data for the Agent in memory, and sign up for a temporary account for you to play around with.

Create a Topic

Let's create a topic using the Apache Kafka client built-in to the WarpStream Agent. We're going to assume in this tutorial you're running the Agent as specified above on localhost, so we'll omit the arguments to specify the Kafka bootstrap URL. Open a second terminal and issue the following command:

warpstream kcmd --type create-topic --topic helloworld2

If you don't receive an error back, your request to create the topic succeeded.

Add Records To The Topic

Now let's write a record to the topic. The kcmd tool writes records with a constant key of "hello", and we'll write two records with the payload of "world" as our example (,, ) is the delimiter).

warpstream kcmd --type produce --topic helloworld2 --records "world,,world"

You should receive output in your terminal that looks something like this:

result: partition:0 offset:0 value:"world" 
result: partition:0 offset:1 value:"world" 

Read Records From The Topic

warpstream kcmd --type fetch --topic helloworld2 --offset 0

Now you should see your records you wrote previously printed to the console. The key is always "hello" and the value field is the same "world" string we wrote before. You can repeat the process of writing another record and running kcmd --type fetch again to read and write more records.

result: partition:0 offset:0 key:"hello" value:"world"
result: partition:0 offset:1 key:"hello" value:"world"

And that's it! You've successfully set up a WarpStream Agent Pool to power your Virtual Cluster, created a topic, and processed some data through it.

You can now move on to trying to create a real application which reads or writes from the topic, or connect your existing tools like Flink to WarpStream.

Last updated

Logo

Apache, Apache Kafka, Kafka, and associated open source project names are trademarks of the Apache Software Foundation. Kinesis is a trademark of Amazon Web Services.