Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-6602

Support for getting primary key from header

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 2.4.0.Alpha1
    • 2.3.0.Final
    • jdbc-connector
    • None

      For some use cases it would be convenient to extract PK from a record's headers (`id` header).

      Specifically, when using Outbox SMT (https://debezium.io/documentation/reference/stable/transformations/outbox-event-router.html), an event's `id` is put in the headers of emitted record

      So the connector could be configured as follows:

          "primary.key.mode": "record_header",
          "primary.key.fields": "id", 

       

      Currently, I need to use an additional SMT (`headerToField`):

       

      {
        "name": "user-db-sink-connector",
        "config": {
          "connector.class": "io.debezium.connector.jdbc.JdbcSinkConnector",
          ...
          "primary.key.mode": "record_value",
          "primary.key.fields": "id",
          "table.name.format": "inbox",
          "max.retries": 1,
          "transforms": "valueToJson,wrapValue,headerToField",
          ...
          "transforms.headerToField.type": "com.github.jcustenborder.kafka.connect.transform.common.HeaderToField$Value",
          "transforms.headerToField.header.mappings": "id:STRING"
        }
      }
       

              blcksrx Hossein Torabi
              romankudryashov Roman Kudryashov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: