Kafka Operations: Difference between revisions
Jump to navigation
Jump to search
(7 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
Followed this procedure: https://kafka.apache.org/documentation/#quickstart | Followed this procedure: https://kafka.apache.org/documentation/#quickstart | ||
Run the server: | |||
<syntaxhighlight lang='bash'> | |||
bin/zookeeper-server-start.sh config/zookeeper.properties | |||
bin/kafka-server-start.sh config/server.properties | |||
</syntaxhighlight> | |||
Create a topic: | |||
<syntaxhighlight lang='bash'> | |||
bin/kafka-topics.sh --create --topic blue --bootstrap-server localhost:9092 | |||
</syntaxhighlight> | |||
Publish: | |||
<syntaxhighlight lang='bash'> | |||
bin/kafka-console-producer.sh --topic blue --bootstrap-server localhost:9092 | |||
</syntaxhighlight> | |||
Consume: | |||
<syntaxhighlight lang='bash'> | |||
bin/kafka-console-consumer.sh --topic blue --from-beginning --bootstrap-server localhost:9092 | |||
</syntaxhighlight> | |||
=Flush a Topic= | |||
<font color=darkkhaki>Did not work, a new client keeps getting all messages from the topic.</font> | |||
<syntaxhighlight lang='bash'> | |||
bin/kafka-delete-records.sh --bootstrap-server localhost:9092 --offset-json-file <file-name> | |||
</syntaxhighlight> | |||
The file content: | |||
<syntaxhighlight lang='json'> | |||
{"partitions": [ | |||
{"topic": "blue", "partition": 0, "offset": 1}], | |||
"version":1 | |||
} | |||
</syntaxhighlight> | |||
=Create a Topic= | |||
<syntaxhighlight lang='bash'> | |||
bin/kafka-topics.sh --create --topic blue --bootstrap-server localhost:9092 | |||
</syntaxhighlight> | |||
=Delete a Topic= | |||
<syntaxhighlight lang='bash'> | |||
bin/kafka-topics.sh --delete --topic blue --bootstrap-server localhost:9092 | |||
</syntaxhighlight> |
Latest revision as of 22:25, 5 October 2023
Internal
Installation
Followed this procedure: https://kafka.apache.org/documentation/#quickstart
Run
Followed this procedure: https://kafka.apache.org/documentation/#quickstart
Run the server:
bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties
Create a topic:
bin/kafka-topics.sh --create --topic blue --bootstrap-server localhost:9092
Publish:
bin/kafka-console-producer.sh --topic blue --bootstrap-server localhost:9092
Consume:
bin/kafka-console-consumer.sh --topic blue --from-beginning --bootstrap-server localhost:9092
Flush a Topic
Did not work, a new client keeps getting all messages from the topic.
bin/kafka-delete-records.sh --bootstrap-server localhost:9092 --offset-json-file <file-name>
The file content:
{"partitions": [
{"topic": "blue", "partition": 0, "offset": 1}],
"version":1
}
Create a Topic
bin/kafka-topics.sh --create --topic blue --bootstrap-server localhost:9092
Delete a Topic
bin/kafka-topics.sh --delete --topic blue --bootstrap-server localhost:9092