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

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

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.

  1. {"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"field":"Id"},
  2. {"type":"string","optional":false,"field":"__dbz__physicalTableIdentifier"}],
  3. "optional":false,"name":"****.Key"},
  4. "payload":{"Id":20030726,"__dbz__physicalTableIdentifier":
  5. "test.***.dbo.Log"}} Timestamp: 2023-02-16 11:05:22.496 Headers: empty
  6. {
  7. "Id": 20030726,
  8. "Date": 1652485947593,
  9. "Thread": "ClusteredScheduler_Worker-9",
  10. "Level": "DEBUG",
  11. "Logger": "Quartz.Core.JobRunShell",
  12. "Message": "Trigger instruction : NoInstruction",
  13. "Exception": "",
  14. "HostName": "****",
  15. "Domain": "*****",
  16. "Identity": "",
  17. "UserName": "*****\\SYSTEM",
  18. "Tier": "AppServer",
  19. "ActivityId": "(null)",
  20. "SessionId": "(null)",
  21. "RequestPath": "(null)",
  22. "DiagnosticsData": "(null)"
  23. }

I've showed as below request to create connector.

  1. curl -X POST -H "Accept:application/json" -H "Content-Type:application/json"
  2. localhost:8083/connectors/ -d '{
  3. "name": "****",
  4. "config": {
  5. "connector.class" : "io.debezium.connector.sqlserver.SqlServerConnector",
  6. "tasks.max" : "1",
  7. "database.server.name" : "test",
  8. "database.hostname" : "****",
  9. "database.port" : "1433",
  10. "database.user" : "*****",
  11. "database.password" : "*****",
  12. "database.dbname" : "******",
  13. "table.include.list" : "dbo.Merchant",
  14. "database.history.kafka.bootstrap.servers" : "******:9092",
  15. "database.history.kafka.topic" : "schema-changes.****",
  16. "tombstones.on.delete" : "false",
  17. "transforms": "Reroute, unwrap",
  18. "transforms.Reroute.type": "io.debezium.transforms.ByLogicalTableRouter",
  19. "transforms.Reroute.topic.regex": "(.*)",
  20. "transforms.Reroute.topic.replacement": "test.****",
  21. "transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState"
  22. }
  23. }'

答案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:

确定