如何从Kafka连接器的响应体中获取特定标头

huangapple go评论55阅读模式
英文:

How can I get specific header from response body in Kafka Connector

问题

以下是从提供的文本中提取的内容:

  1. 从给定的JSON体中提取“ID”字段。

  2. 创建连接器的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

huangapple
  • 本文由 发表于 2023年2月16日 19:11:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75471421.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定