简体   繁体   English

kafka-streams:在将消息结构发送到kafka主题之前修改消息结构

[英]kafka-streams : to modify message structure before sending it to kafka topics

I have a scenario where I need to change the message structure which I am getting from JDBC source connector before it hits to kafka . 我有一种情况,我需要更改从JDBC源连接器获得的消息结构,然后再将其发送到kafka。 I am a beginner to kafka so how kafka streams can help me in achieving this . 我是kafka的初学者,因此kafka流如何帮助我实现这一目标。

Input - 输入-

{"id":"123","firstName":"pqr","lastName":"xyz","age":"23","dob":"20-09-1995"} 

I want to store this in elasticseacrh index as 我想将此存储在elasticseacrh索引中

{"id":"123","name":{"firstName":"pqr","lastName":"xyz"},"age":"23","dob":"20-09-1995"} 

I am not set on kafka streams, I thought to use it, if using KSQL is possible i want to know that. 我没有在kafka流上设置,我想使用它,如果可以使用KSQL,我想知道这一点。

It seems you are using Kafka Connect. 看来您正在使用Kafka Connect。 For this case, "Single Message Transform" (SMT) are your friend. 对于这种情况,“单消息转换”(SMT)是您的朋友。 Those allows you to transform each message one-by-one before the connector writes the data into the topic. 这些使您可以在连接器将数据写入主题之前,对每个消息进行一次转换。

Check out this blog post for more details: https://www.confluent.io/blog/simplest-useful-kafka-connect-data-pipeline-world-thereabouts-part-3/ 请查看此博客文章以获取更多详细信息: https : //www.confluent.io/blog/simplest-useful-kafka-connect-data-pipeline-world-thereabouts-part-3/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM