# Convert message key (Debezium + Kafka Connect)

**URL:** <https://forum.confluent.io/t/convert-message-key-debezium-kafka-connect/1742>\
**Category:** Kafka Connect\
**Created:** [11 May 2021 18:55 UTC](https://forum.confluent.io/t/convert-message-key-debezium-kafka-connect/1742 "2021-05-11T18:55:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpau](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/jpau/32/769_2.png) [@jpau](https://forum.confluent.io/u/jpau)\
**Post date:** [11 May 2021 18:55 UTC](https://forum.confluent.io/t/convert-message-key-debezium-kafka-connect/1742/1 "2021-05-11T18:55:09Z")

</div>

Hi everyone!

I am working with Debezium MySQL connector and Kafka Connect.

This is my connector configuration:

```
{
  "name": "source-mysql-connector",
  "config": {
    "connector.class": "io.debezium.connector.mysql.MySqlConnector",
    "tasks.max": "1",
    "database.hostname": "mysql",
    "database.port": "3306",
    "database.user": "debezium",
    "database.password": "dbz",
    "database.server.id": "184054",
    "database.server.name": "dbserver",
    "database.include.list": "inventory",
    "database.history.kafka.bootstrap.servers": "broker:29092",
    "database.history.kafka.topic": "debezium_dbhistory",
    "include.schema.changes": "true",
    "key.converter":"io.confluent.connect.avro.AvroConverter",
    "key.converter.schemas.enable":"true",
    "key.converter.schema.registry.url":"http://schema-registry:8081",
    "value.converter":"io.confluent.connect.avro.AvroConverter",
    "value.converter.schema.registry.url":"http://schema-registry:8081",
    "after.state.only":"true",
    "transforms":"unwrap",
    "transforms.unwrap.type":"io.debezium.transforms.ExtractNewRecordState"
  }
}

```

The event generated in topic looks like:

> KEY: { “id”: 4 }  
> VALUE: {“id”: 4, “order\_date”: “2021-05-11T18:47:50Z”, “customer\_id”: 1004}

I would like to have this:

> KEY: 4  
> VALUE: {“id”: 4, “order\_date”: “2021-05-11T18:47:50Z”, “customer\_id”: 1004}

Is there a way to convert the key to that?

PD. I’ve been trying different transformations (org.apache.kafka.connect.transforms.ExtractField$Key, etc.) but none have worked ☹

Somebody could help me?  
Thanks & regards

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [10 June 2021 18:55 UTC](https://forum.confluent.io/t/convert-message-key-debezium-kafka-connect/1742/2 "2021-06-10T18:55:45Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
