title: KafkaProducer round-robin distribution not working for the same key
body: <p>I'm trying to understand how Kafka works. I've read that by default Kafka will distribute the messages from a producer in a round-robin fashion among the partitions.</p>
  
  <p>But, why are the messages always put in the same partition if the messages have the same key ? (no partition key strategy configured).</p>
  
  <p>For instance, using the code below the messages are always put in the same partition:</p>
  
  <pre><code>KafkaProducer&lt;String, String&gt; producer = new KafkaProducer&lt;&gt;(properties);
  String key = properties.getProperty("dev.id");
  producer.send(new ProducerRecord&lt;String, String&gt;(properties.getProperty("kafka.topic"), key, value), new EventGeneratorCallback(key));
  </code></pre>
  
  <p>With a different key, messages are distributed in a round-robin fashion:</p>
  
  <pre><code>KafkaProducer&lt;String, String&gt; producer = new KafkaProducer&lt;&gt;(properties);
  String key = properties.getProperty("dev.id") + UUID.randomUUID().toString();
  producer.send(new ProducerRecord&lt;String, String&gt;(properties.getProperty("kafka.topic"), key, value), new EventGeneratorCallback(key));
  </code></pre>