B. Because Kafka always reorders messages regardless of keys.
C. Because messages with null keys can go to different partitions, losing order.
D. Because the producer is synchronous.
Solution
Step 1: Analyze key usage in ProducerRecord
Null keys mean Kafka uses round-robin or default partitioner, sending messages to different partitions.
Step 2: Understand ordering impact
Messages in different partitions have no ordering guarantee, so order may be lost.
Final Answer:
Because messages with null keys can go to different partitions, losing order. -> Option C
Quick Check:
Null key = no partition order guarantee [OK]
Hint: Null keys cause messages to spread partitions, breaking order [OK]
Common Mistakes:
Thinking Kafka always orders messages
Assuming one partition means no order loss
Confusing synchronous with ordering guarantee
5. You want to ensure strict message order for user events in Kafka. You have multiple users sending events simultaneously. Which approach best guarantees order per user?
hard
A. Send all messages without keys to a single partition topic.
B. Use multiple topics, one per user, to keep order.
C. Use random keys to balance load and rely on consumer ordering.
D. Use the user ID as the message key so all events for a user go to the same partition.
Solution
Step 1: Identify how Kafka partitions messages
Kafka uses the key to assign messages to partitions; same key means same partition.
Step 2: Apply to user event ordering
Using user ID as key ensures all events for that user go to one partition, preserving order.
Step 3: Evaluate other options
Sending without keys or random keys breaks order; multiple topics is complex and inefficient.
Final Answer:
Use the user ID as the message key so all events for a user go to the same partition. -> Option D
Quick Check:
User ID key = per-user order guaranteed [OK]
Hint: Key by user ID to keep their events ordered [OK]
Common Mistakes:
Sending messages without keys expecting order
Using random keys and expecting order
Creating many topics instead of using keys
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.