英文:
How can I get specific header from response body in Kafka Connector
问题
以下是从提供的文本中提取的内容:
-
从给定的JSON体中提取“ID”字段。
-
创建连接器的CURL请求。
请注意,这是从您的原始文本中提取的关键信息。
英文:
There is a response which is belong apache kafka-connect, I want to get just "ID" from that body. Is there any way in order to eliminate that body.
{"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"field":"Id"},
{"type":"string","optional":false,"field":"__dbz__physicalTableIdentifier"}],
"optional":false,"name":"****.Key"},
"payload":{"Id":20030726,"__dbz__physicalTableIdentifier":
"test.***.dbo.Log"}} Timestamp: 2023-02-16 11:05:22.496 Headers: empty
{
"Id": 20030726,
"Date": 1652485947593,
"Thread": "ClusteredScheduler_Worker-9",
"Level": "DEBUG",
"Logger": "Quartz.Core.JobRunShell",
"Message": "Trigger instruction : NoInstruction",
"Exception": "",
"HostName": "****",
"Domain": "*****",
"Identity": "",
"UserName": "*****\\SYSTEM",
"Tier": "AppServer",
"ActivityId": "(null)",
"SessionId": "(null)",
"RequestPath": "(null)",
"DiagnosticsData": "(null)"
}
I've showed as below request to create connector.
curl -X POST -H "Accept:application/json" -H "Content-Type:application/json"
localhost:8083/connectors/ -d '{
"name": "****",
"config": {
"connector.class" : "io.debezium.connector.sqlserver.SqlServerConnector",
"tasks.max" : "1",
"database.server.name" : "test",
"database.hostname" : "****",
"database.port" : "1433",
"database.user" : "*****",
"database.password" : "*****",
"database.dbname" : "******",
"table.include.list" : "dbo.Merchant",
"database.history.kafka.bootstrap.servers" : "******:9092",
"database.history.kafka.topic" : "schema-changes.****",
"tombstones.on.delete" : "false",
"transforms": "Reroute, unwrap",
"transforms.Reroute.type": "io.debezium.transforms.ByLogicalTableRouter",
"transforms.Reroute.topic.regex": "(.*)",
"transforms.Reroute.topic.replacement": "test.****",
"transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState"
}
}'
答案1
得分: 0
可以使用ExtractField转换来获取只有一个字段。
要在提取后将键添加回值,还可以使用HoistField转换。
英文:
You can use ExtractField transform to get only one field.
To add the key back to the value after extraction, you can also use HoistField transform
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论