Skip to content

Commit

Permalink
Merge pull request #11 from anasabbal/readme
Browse files Browse the repository at this point in the history
update README.md
  • Loading branch information
anasabbal authored Jan 10, 2023
2 parents d95e8b3 + 8c36dc0 commit 330909f
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,63 @@ cd Donwloads
```
PATH="$PATH:/Users/yourusername/kafka_2.13-3.1.0/bin"
```

# Basic Kafka
Apache Kafka depends on Zookeeper for cluster management, first step we need to start Zookeeper
```
➜ ~zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties
[2023-01-10 01:55:30,922] INFO KafkaConfig values:
advertised.listeners = null
alter.config.policy.class.name = null
alter.log.dirs.replication.quota.window.num = 11
alter.log.dirs.replication.quota.window.size.seconds = 1
authorizer.class.name =
auto.create.topics.enable = true
auto.leader.rebalance.enable = true
background.threads = 10
broker.heartbeat.interval.ms = 2000
broker.id = 0
broker.id.generation.enable = true
broker.rack = null
broker.session.timeout.ms = 9000
.
.
.
```
After that we run kafka server
```
➜ ~kafka-server-start /usr/local/etc/kafka/server.properties
Manager$ThrottledChannelReaper)
[2023-01-10 01:58:54,857] INFO [ThrottledChannelReaper-Request]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2023-01-10 01:58:54,864] INFO [ThrottledChannelReaper-ControllerMutation]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2023-01-10 01:58:55,015] INFO Loading logs from log dirs ArraySeq(/usr/local/var/lib/kafka-logs) (kafka.log.LogManager)
[2023-01-10 01:58:55,029] INFO Skipping recovery for all logs in /usr/local/var/lib/kafka-logs since clean shutdown file was found (kafka.log.LogManager)
[2023-01-10 01:58:55,097] INFO Loaded 0 logs in 81ms. (kafka.log.LogManager)
[2023-01-10 01:58:55,100] INFO Starting log cleanup with a period of 300000 ms. (kafka.log.LogManager)
[2023-01-10 01:58:55,111] INFO Starting log flusher with a default period of 9223372036854775807 ms. (kafka.log.LogManager)
[2023-01-10 01:58:55,700] INFO [feature-zk-node-event-process-thread]: Starting (kafka.server.FinalizedFeatureChangeListener$ChangeNotificationProcessorThread)
[2023-01-10 01:58:55,801] INFO [MetadataCache brokerId=0] Updated cache from existing <empty> to latest FinalizedFeaturesAndEpoch(features=Map(), epoch=0). (kafka.server.metadata.ZkMetadataCache)
[2023-01-10 01:58:55,930] INFO [BrokerToControllerChannelManager broker=0 name=forwarding]: Starting (kafka.server.BrokerToControllerRequestThread)
[2023-01-10 01:58:57,421] INFO Updated connection-accept-rate max connection creation rate to 2147483647 (kafka.network.ConnectionQuotas)
```
Creat a topic is a category or feed name to which records are published. Topics in Kafka are always multi-subscriber; that is, a topic can have zero, one, or many consumers that subscribe to the data written to it
```
$ kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
```
Initialize Producer console
```
$ kafka-console-producer --broker-list localhost:9092 --topic test
>send first message
>send second message
>wow it is working
```
Initialize Consumer console
```
$ kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginningsend
first message
send second message
wow it is working
```
!!! Congratulation
# Apache Kafka Example
Consumer Config
```java
Expand Down

0 comments on commit 330909f

Please sign in to comment.