Complete the code to specify the broker address in the Kafka producer configuration.
producer = KafkaProducer(bootstrap_servers='[1]')
The bootstrap_servers parameter requires the broker address with port 9092, which is the default Kafka broker port.
Complete the code to list all broker nodes in a Kafka cluster using the AdminClient.
admin_client = AdminClient({'bootstrap.servers': '[1]'})
brokers = admin_client.describe_cluster().brokersThe bootstrap.servers config must point to the Kafka broker address, usually on port 9092.
Fix the error in the code to correctly connect to a Kafka broker node.
consumer = KafkaConsumer('my_topic', bootstrap_servers='[1]')
The bootstrap_servers must be the Kafka broker address with port 9092, not Zookeeper or other ports.
Fill both blanks to create a dictionary comprehension that maps broker IDs to their hostnames.
broker_map = {broker.[1]: broker.[2] for broker in cluster.brokers()}port or name instead of host.id and host.Each broker has an id and a host attribute. We map IDs to hostnames.
Fill all three blanks to filter brokers with port greater than 9092 and create a dictionary of their IDs and hosts.
filtered_brokers = {broker.[1]: broker.[2] for broker in cluster.brokers() if broker.[3] > 9092}id or host instead of port.We use id and host to build the dictionary and filter by port greater than 9092.