0
0
Kafkadevops~10 mins

MirrorMaker 2 concept in Kafka - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - MirrorMaker 2 concept
Start MirrorMaker 2
Connect to Source Cluster
Read Topics from Source
Apply Filters and Transformations
Produce to Target Cluster
Monitor Replication Status
Handle Failures and Retries
End
MirrorMaker 2 connects two Kafka clusters, reads topics from the source, optionally transforms data, and writes it to the target cluster while monitoring and handling errors.
Execution Sample
Kafka
connect source_cluster
read topic 'orders'
filter messages with key 'user'
produce to target_cluster
monitor replication
handle errors
This sequence shows MirrorMaker 2 connecting to a source cluster, reading a topic, filtering messages, sending them to a target cluster, and monitoring the process.
Process Table
StepActionDetailsResult
1Connect to source clusterConnect to kafka-source.example.comConnection established
2Read topicRead messages from 'orders' topicMessages fetched
3Filter messagesKeep messages with key 'user'Filtered messages ready
4Produce to target clusterSend filtered messages to kafka-target.example.comMessages produced
5Monitor replicationCheck offsets and lagReplication healthy
6Handle errorsRetry on failureErrors handled or logged
7EndReplication complete or stoppedProcess ends
💡 Replication ends when stopped manually or on unrecoverable error
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 5Final
connection_statusdisconnectedconnectedconnectedconnectedconnecteddisconnected
messages_fetched010001000100010000
messages_filtered006006006000
messages_produced000600600600
replication_healthunknownunknownunknownunknownhealthystopped
Key Moments - 3 Insights
Why do we filter messages after reading them from the source?
Filtering happens after reading to select only relevant messages for replication, as shown in step 3 of the execution_table where messages are filtered by key.
What happens if the connection to the target cluster fails during production?
MirrorMaker 2 retries sending messages and handles errors as shown in step 6, ensuring replication continues or logs failures.
When does the replication process stop?
Replication stops manually or on unrecoverable errors as noted in the exit_note and step 7 of the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the number of messages filtered after step 3?
A600
B1000
C0
D400
💡 Hint
Check the 'messages_filtered' variable in variable_tracker after step 3
At which step does MirrorMaker 2 check the replication health?
AStep 4
BStep 2
CStep 5
DStep 6
💡 Hint
Look at the 'Monitor replication' action in the execution_table
If the connection to the source cluster fails at step 1, what happens next?
AReplication proceeds without source connection
BProcess cannot continue and stops
CMessages are filtered anyway
DMessages are produced to target cluster
💡 Hint
Refer to step 1 in execution_table where connection is established; failure means no further steps
Concept Snapshot
MirrorMaker 2 replicates Kafka topics between clusters.
It connects to source, reads topics, filters or transforms messages.
Then it produces messages to the target cluster.
It monitors replication health and handles errors.
Replication stops manually or on unrecoverable errors.
Full Transcript
MirrorMaker 2 is a tool that copies data from one Kafka cluster to another. It starts by connecting to the source cluster, then reads messages from specified topics. After reading, it can filter or transform messages before sending them to the target cluster. During this process, it monitors the replication status to ensure data is copied correctly. If errors happen, it retries or logs them. The process continues until stopped manually or if a serious error occurs.