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


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


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",
"": "{\"<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:

1 Like

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