SNSB – creating a topic, producer, and consumer
The SNSB Kafka cluster is running; now let's create topics, producer, and consumer.
Getting ready
We need the previous recipe executed:
- Kafka already installed
- ZooKeeper up and running
- A Kafka server up and running
- Now, go to the Kafka installation directory (
/usr/local/kafka/
for macOS users and/opt/kafka/
for Linux users):
> cd /usr/local/kafka
How to do it...
The following steps will show you how to create an SNSB topic, producer, and consumer.
Creating a topic
- As we know, Kafka has a command to create topics. Here we create a topic called
SNSBTopic
with one partition and one replica:
> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic SNSBTopic
We obtain the following output:
Created topic "SNSBTopic".
The command parameters are:
--replication-factor 1
: This indicates just one replica--partition 1
: This indicates just one partition--zookeeper localhost:2181
: This indicates the ZooKeeper URL
- As...