Apache Kafka Quickstart
Apache Kafka Quickstart
org/quickstart
1 of 9 5/13/25, 7:42 AM
Apache Kafka https://kafka.apache.org/quickstart
Kafka can be run using local scripts and downloaded files or the docker
$ KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid
$ bin/kafka-server-start.sh config/server.properties
Once the Kafka server has successfully launched, you will have a basic
Kafka environment running and ready to use.
2 of 9 5/13/25, 7:42 AM
Apache Kafka https://kafka.apache.org/quickstart
Kafka is a distributed event streaming platform that lets you read, write,
store, and process events (also called records or messages in the
documentation) across many machines.
So before you can write your first events, you must create a topic. Open
another terminal session and run:
All of Kafka's command line tools have additional options: run the
kafka-topics.sh command without any arguments to display usage
information. For example, it can also show you details such as the partition
count of the new topic:
A Kafka client communicates with the Kafka brokers via the network for
writing (or reading) events. Once received, the brokers will store the events
3 of 9 5/13/25, 7:42 AM
Apache Kafka https://kafka.apache.org/quickstart
You can stop the producer client with Ctrl-C at any time.
Open another terminal session and run the console consumer client to read
the events you just created:
You can stop the consumer client with Ctrl-C at any time.
Feel free to experiment: for example, switch back to your producer terminal
(previous step) to write additional events, and see how the events
immediately show up in your consumer terminal.
Because events are durably stored in Kafka, they can be read as many
times and by as many consumers as you want. You can easily verify this by
opening yet another terminal session and re-running the previous
command again.
4 of 9 5/13/25, 7:42 AM
Apache Kafka https://kafka.apache.org/quickstart
In this quickstart we'll see how to run Kafka Connect with simple
connectors that import data from a file to a Kafka topic and export data
from a Kafka topic to a file.
Or on Windows:
Next, we'll start two connectors running in standalone mode, which means
5 of 9 5/13/25, 7:42 AM
Apache Kafka https://kafka.apache.org/quickstart
GET configuration
DOCSfiles as parameters.
POWERED The first is always the configuration
COMMUNITY APACHE for DOWNLOAD
STARTED BY KAFKA
the Kafka Connect process, containing common configuration such as the
Kafka brokers to connect to and the serialization format for data. The
remaining configuration files each specify a connector to create. These
files include a unique connector name, the connector class to instantiate,
and any other configuration required by the connector.
These sample configuration files, included with Kafka, use the default local
cluster configuration you started earlier and create two connectors: the first
is a source connector that reads lines from an input file and produces each
to a Kafka topic and the second is a sink connector that reads messages
from a Kafka topic and produces each as a line in an output file.
$ more test.sink.txt
foo
bar
Note that the data is being stored in the Kafka topic connect-test , so
we can also run a console consumer to see the data in the topic (or use
custom consumer code to process it):
The connectors continue to process data, so we can add data to the file
6 of 9 5/13/25, 7:42 AM
Apache Kafka https://kafka.apache.org/quickstart
You should see the line appear in the console consumer output and in the
sink file.
Once your data is stored in Kafka as events, you can process the data with
the Kafka Streams client library for Java/Scala. It allows you to implement
mission-critical real-time applications and microservices, where the input
and/or output data is stored in Kafka topics. Kafka Streams combines the
simplicity of writing and deploying standard Java and Scala applications on
the client side with the benefits of Kafka's server-side cluster technology to
make these applications highly scalable, elastic, fault-tolerant, and
distributed. The library supports exactly-once processing, stateful
operations and aggregations, windowing, joins, processing based on event-
time, and much more.
To give you a first taste, here's how one would implement the popular
WordCount algorithm:
The Kafka Streams demo and the app development tutorial demonstrate
how to code and run such a streaming application from start to finish.
7 of 9 5/13/25, 7:42 AM
Apache Kafka https://kafka.apache.org/quickstart
Now that you reached the end of the quickstart, feel free to tear down the
Kafka environment—or continue playing around.
If you also want to delete any data of your local Kafka environment
including any events you have created along the way, run the command:
CONGRATULATIONS!
• Read through the brief Introduction to learn how Kafka works at a high
level, its main concepts, and how it compares to other technologies. To
understand Kafka in more detail, head over to the Documentation.
• Browse through the Use Cases to learn how other users in our world-
wide community are getting value out of Kafka.
• Join a local Kafka meetup group and watch talks from Kafka Summit,
the main conference of the Kafka community.
The contents of this website are © 2024 Apache Software Foundation under the terms of the Apache License v2. Apache Kafka, Kafka, and the Kafka logo are either registered
trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
8 of 9 5/13/25, 7:42 AM
Apache Kafka https://kafka.apache.org/quickstart
9 of 9 5/13/25, 7:42 AM