Please enable JavaScript.
Coggle requires JavaScript to display documents.
TOOLS - Coggle Diagram
TOOLS
KAFKA
Introduction
-
Messaging System
-
Patterns
Point to Point
- Producer send msg in the queue and only one Consumer can retreive it.
- When the msg is consumed it disappears from the queue
- Exp: Order syst => Order made - put in queue - handle buy one consumer - Disappear
Publish-Subscribe (Pub-Sub)
- Msg are persisted in a Topic, sent by Publishers and retreived by Subscriber
- Consumers can subscribe to many topics and consume all msgs
- Exp: Tv publish channels - anyone subscribe to a set of channels - Watch channel when available
Benefits
Reliability − Distributed, partitioned, replicated and fault tolerance.
-
-
-
US
-
Log Aggregation Solution - collect, format and centralise logs from apps for consumers
-
-
Drawback
-
General topic selection is not supported by Kafka, exact topic name is required.
Some message paradigms (point-to-point queues, request/reply) are not supported by Kafka
-
Core
Components
-
-
-
-
-
-
-
-
-
-
:warning:
- Leader fails => a follower becomes leader and retrieve data of the preview leader
- Topic with N partitions + M brokers => N == M (1 part/brok) | N > M ( 1part on N broks) | N < M (x part/brok No load balance)
-
-
-
-
Zookeeper
-
Roles
Maintain and coordinate the kafka cluster => Notify the cluster/consumer in case of new/delete topic/broker
-
Save metadata of cluster => save state information of broker (topics, brokers, consumer offsets ...)
-
Workflow
-
-
:warning:
- Only one consumer/group can be listen to a partition but consumer can listen to many partitions
- If 3N partitions + N consumers in a group =>1 consumer listen to 3 partitions => The messages are divided between consumers
In Action
Installation
-
-
-
-
5- Create a Topic in CMD : bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092
6- Create a Producer in CMD: bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server localhost:9092
Create a Consumer in CMD: bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server localhost:9092
Create a cluster
1- Create kafka config files of your brokers by setting the brokerId, the port and the log name
-
-
-
Integration
JMS + RabbitMQ
Differences
Implement the request/Reply, Point-to-Point and Pub-Sub pattern
-
-
-
-
-
-
Spring
-
2- Create a producer bean with serializer, server host ...
3- Create a Consumer bean with host, groupID, serializer ...
Add @ EnableKafka on the config File
-
5- Use @ KafkaListener (topics= "...", groupId = "...") above a method to get the message
-
GIT
Fundamental
Definitions
-
VCS
Version Control System (VCS) = software that helps developers to work together and maintain a complete history of their work :
-
Features
-
-
Distributed – No central repository, each user has their own repository and can push the changes to a remote repository
Security – Git uses the SHA1 (Secure Hash Function) to name and identify objects within its repository
-
Supports non-linear development – A branch represents a single commit and a full branch structure can be constructed with the parental commit.
Branching and Merging – Create, delete and merge on branches
Benefits
-
Offline working – Because of distributed feature, we can work locally without internet
-
Track the changes – Track changes with Diff, Log and Status
-
Getting Start
-
-
Terminology
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Git Reset – undoing changes (Soft, Mixed, Hard)
-
Git Diff – Runs a diff function on Git data sources (Files, branches, commits ...)
-
-
-
-
-
Workflows
-
-
GitFlow workflow
Use of features branches and multiple primary branches (main, hotfix, release, dev and feature)
-
Forking Workflow
-
Steps
1- A developer 'forks' an 'official' server-side repository. This creates their own server-side copy.
-
-
-
-
-
-
-
-
Commands
Staging/Commit
-
Git add [filename | option] – Add files to index(Staging area)
-A / . => Add all modified files, new files and deleted files
add a file twice | git reset <filename> => Remove the file from the index
--ignore-removal => add all without deleted files
*.java => Add Files by Wildcard
Git commit [option] [value] - Record the changes in the repository
-a => to add file already existed and not new files
-m "..." => commit with message directly
-am "..." => -a + -m
-amend => modify or merge changes with the last commit
Git clone [-b branchName] [GitLink] [folderName]
[-b branchName] => clone a specific branch
[folderName] => name of the folder
-
Git stash [option] – Put your changes on hold while changing branch
save "..." => saving stashes with message
list => check the stored stashes
apply [stashId] => Apply the last stash or a specific stash
show [-p] => List the modify files with content (-p)
pop [stashId] => Apply and remove the last stash or a specific stash
drop [stashId] => remove the last stash or a specific stash
clear => Delete all stashes
branch "branchName" => Create a branch and apply last stash on it