SNMB – creating a topic, producer, and consumer
The SNMB 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 SNMB topic, producer, and consumer
Creating a topic
- Using the command to create topics, let's create a topic called
SNMBTopic
with two partitions and two replicas:
> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 2 --partitions 3 --topic SNMBTopic
The following output is displayed:
Created topic "SNMBTopic".
This command has the following effects:
- Kafka will create three logical partitions for the topic.
- Kafka will create two replicas (copies) per partition. This means, for each partition it will pick two brokers...