Complete the code to set the number of partitions for a Kafka topic.
newTopic = NewTopic('my-topic', [1], replication_factor=1)
The number of partitions must be an integer, so 3 is correct.
Complete the code to configure the consumer group id.
consumer = KafkaConsumer('my-topic', group_id=[1], bootstrap_servers=['localhost:9092'])
The group_id must be a string identifying the consumer group.
Fix the error in setting the retention time for a topic.
topic_config = {'retention.ms': [1]Kafka expects retention.ms as an integer representing milliseconds.
Fill both blanks to create a producer with acks set to all and retries set to 5.
producer = KafkaProducer(acks=[1], retries=[2])
Setting acks to 'all' ensures all replicas acknowledge. Retries should be an integer like 5.
Fill all three blanks to create a topic with 4 partitions, replication factor 2, and cleanup policy set to compact.
newTopic = NewTopic('[1]', [2], replication_factor=[3], topic_configs={'cleanup.policy': 'compact'})
The topic name is 'my-topic', partitions are 4, and replication factor is 2 for fault tolerance.
