Convert message key (Debezium + Kafka Connect)

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 :frowning:

Somebody could help me?
Thanks & regards

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