kafka jdbc connect:基于消息字段中的多个值插入键

mctunoxg  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(500)

我有以下关于jdbc连接器发布到的主题的json

{"APP_SETTING_ID":9,"USER_ID":10,"APP_SETTING_NAME":"my_name","SETTING_KEY":"my_setting_key"}

这是我的连接器文件

name=data.app_setting
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
poll.interval.ms=500
tasks.max=4
mode=timestamp
query=SELECT APP_SETTING_ID, APP_SETTING_NAME, SETTING_KEY,FROM MY_TABLE with (nolock)
timestamp.column.name=LAST_MOD_DATE
topic.prefix=data.app_setting

key.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable=false
value.converter=org.apache.kafka.connect.json.JsonConverter
value.converter.schemas.enable=false

我现在想通过将两个整数字段相乘来插入此消息的键- APP_SETTING_ID 以及 USER_ID . 所以这个信息的关键是 9*10 = 90 这种转变是否可能通过连接,如果是的话,请有人阐明它

wbgh16ku

wbgh16ku1#

我想看看你能走多远

query=SELECT APP_SETTING_ID, APP_SETTING_NAME, SETTING_KEY, (APP_SETTING_ID*USER_ID) as _key FROM MY_TABLE with (nolock)

然后添加一个extractkey变换

transforms=AddKeys,ExtractKey

# this make a map

transforms.AddKeys.type=org.apache.kafka.connect.transforms.ValueToKey
transforms.AddKeys.fields=_key  

# this gets one field from the map

transforms.ExtractKey.type=org.apache.kafka.connect.transforms.ExtractField$Key
transforms.ExtractKey.field=_key

相关问题