title: How to send data as key/value to Kafka using Apache Flink with Specific Partitioner
body: <p>I have a payload in Flink like below;</p>
  <pre><code>{
      &quot;memberId&quot;: 4
      &quot;total&quot;: 5
  }
  </code></pre>
  <p>I want to send data to kafka as key-value format with specified partitioner. For partitioner, i'll use Modulo partitioner.</p>
  <p>An example for modulo partitioner;</p>
  <p><code>partitionId = value % numPartitions</code></p>
  <p>Let's assume <code>numPartitions</code> parameter is 3. If we can use memberId of the payload defined above, partitionId should be <code>4 % 3</code> = 1</p>
  <p>According to the above partitioner, I want to send data that have the same partitionId to the same kafka topic. Another examples;</p>
  <p>If(assume numPartitions = 3);</p>
  <pre><code>memberId: 3 =&gt; (3 % 3) =&gt; partitionId = 0 =&gt; kafka partition 1
  memberId: 8 =&gt; (8 % 3) =&gt; partitionId = 2 =&gt; kafka partition 2
  memberId: 2 =&gt; (2 % 3) =&gt; partitionId = 2 =&gt; kafka partition 2
  memberId: 6 =&gt; (6 % 3) =&gt; partitionId = 0 =&gt; kafka partition 1
  memberId: 7 =&gt; (7 % 3) =&gt; partitionId = 1 =&gt; kafka partition 2
  </code></pre>
  <p>If I'm not wrong, flink kafka producer uses FlinkFixedPartitioner if we can not specify any key and partition function. If we set partition function as <code>null</code>, flink kafka producer will use round robin distribution. But i don't know how can i send data to kafka as key/value format, how can i partition it by modulo. How can i achieve that?</p>