Change kafka message structure of mongodb kafka connector

How can I change structure of the message that is written to kafka by mongodb kafka connector?
By default it writes message like below

{"schema":{"type":"string","optional":false},"payload":"<updated_document>"}

But I just want the payload i.e. the message I want to be written is like

{<updated_document>}

My source config is

"connector.class": "com.mongodb.kafka.connect.MongoSourceConnector",
"connection.uri": "mongodb://mongo/?replicaSet=rs0",
"database": "<db_name>",
"collection": "<collection_name>",
"publish.full.document.only": "true",
"topic.namespace.map": "{\"<db_name>.<collection_name>\": \"<kafka_topic_name>\"}"

Is that your complete source config? What converter are you using? StringConverter or JsonConverter?

Try String Converter something like this:

key.converter.schemas.enable=false
value.converter.schemas.enable=false
key.converter=org.apache.kafka.connect.storage.StringConverter
value.converter=org.apache.kafka.connect.storage.StringConverter
1 Like

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