Null means "choose a partition for me"; an empty string is a real key that always hashes the same way.
new ProducerRecord<>("orders", null, payload); // sticky partitioner
new ProducerRecord<>("orders", "", payload); // murmur2("") - one partition
null: spread across all partitions in batches
"" : every record to the SAME partition - an accidental hot partition
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11