Complete the code to set the replication factor for a Kafka topic.
bin/kafka-topics.sh --create --topic my-topic --partitions 3 --replication-factor [1] --bootstrap-server localhost:9092
The replication factor defines how many copies of the data exist across different brokers or datacenters. Setting it to 3 ensures data is replicated in multiple places for availability.
Complete the code to configure Kafka producer to wait for acknowledgments from all replicas.
props.put("acks", "[1]");
Setting 'acks' to 'all' ensures the producer waits for all replicas to acknowledge the write, improving availability and durability.
Fix the error in the consumer configuration to enable automatic failover across datacenters.
props.put("group.id", "my-group"); props.put("enable.auto.commit", [1]);
Setting 'enable.auto.commit' to true (boolean) allows the consumer to commit offsets automatically, helping with failover and availability.
Fill both blanks to create a Kafka topic with a replication factor and enable unclean leader election.
bin/kafka-topics.sh --create --topic logs --partitions 5 --replication-factor [1] --config [2]=true --bootstrap-server localhost:9092
Replication factor 3 ensures data is on multiple brokers. Enabling 'unclean.leader.election.enable' allows leader election even if some replicas are out of sync, improving availability but risking data loss.
Fill all three blanks to configure a Kafka consumer to read from multiple datacenters with failover.
props.put("bootstrap.servers", "[1]"); props.put("group.id", "[2]"); props.put("auto.offset.reset", "[3]");
Setting bootstrap servers to multiple datacenters allows failover. Group id identifies the consumer group. 'auto.offset.reset' to 'earliest' ensures the consumer reads from the beginning if no offset is found.