title: How to set the key of the JDBC source connector (kafka)?
body: <p>I'm reading data from a <a href="/questions/tagged/mysql" class="post-tag" title="show questions tagged &#39;mysql&#39;" rel="tag">mysql</a> database table using a <code>Kafka Source JDBC connector</code> and publishing it to the topic <code>test-mysql-petai</code>.  </p>
  
  <p>The database table has 2 fields where <code>Id</code> is the primary key:</p>
  
  <pre><code>+---------+-------------+------+-----+---------+----------------+
  | Field   | Type        | Null | Key | Default | Extra          |
  +---------+-------------+------+-----+---------+----------------+
  | id      | int(11)     | NO   | PRI | NULL    | auto_increment |
  | name    | varchar(20) | YES  |     | NULL    |                |
  +---------+-------------+------+-----+---------+----------------+
  </code></pre>
  
  <p>I need the value of the <code>id</code> field to be the Key of the topic. I tried adding a transformation to the jdbc connector properties.</p>
  
  <p>JDBCConnector.properties:</p>
  
  <pre><code>name=jdbc-source-connector    
  connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
  tasks.max=1   
  connection.url=jdbc:mysql://127.0.0.1:3306/test?user=dins&amp;password=pw&amp;serverTimezone=UTC
  table.whitelist=petai 
  mode=incrementing
  incrementing.column.name=id    
  schema.pattern=""    
  transforms=createKey,extractInt    
  transforms.createKey.type=org.apache.kafka.connect.transforms.ValueToKey    
  transforms.createKey.fields=id    
  transforms.extractInt.type=org.apache.kafka.connect.transforms.ExtractField$Key    
  transforms.extractInt.field=id    
  topic.prefix=test-mysql-jdbc-
  </code></pre>
  
  <p>But, when I read the keys and values using a consumer, I get following:</p>
  
  <pre><code>Key = {"schema":{"type":"int32","optional":false},"payload":61} 
  Value ={"id":61,"name":"ttt"}
  </code></pre>
  
  <p>I need to get the following:</p>
  
  <pre><code>Key = 61    
  Value ={"id":61,"name":"ttt"}
  </code></pre>
  
  <p>What am I doing wrong? Any help is appreciated.</p>
  
  <p>Thank you.</p>