Complete the code to assign a consumer to a group.
consumer = KafkaConsumer('my_topic', group_id=[1])
The group_id parameter assigns the consumer to a consumer group, enabling parallel processing.
Complete the code to start consuming messages in parallel.
for message in consumer.[1](): print(message.value)
The poll() method fetches messages for processing.
Fix the error in the code to enable parallel processing with consumer groups.
consumer = KafkaConsumer('my_topic', group_id=[1]) consumer.subscribe(['my_topic'])
Setting group_id to a group name enables parallel processing by dividing partitions among consumers.
Fill both blanks to create a dictionary comprehension that maps partitions to consumers in a group.
partition_map = {partition: consumer[1] for partition in partitions if partition [2] 0}The assign() method assigns partitions to consumers, and > 0 filters partitions.
Fill all three blanks to create a dictionary comprehension that filters messages by offset and assigns them to a consumer group.
filtered_messages = {msg[1]: msg.value for msg in messages if msg.offset [2] [3]We use .key as dictionary keys, filter messages with offset greater than 100.