Is it a good practice to do sync database query or restful call in Kafka streams jobs?

心不动则不痛 提交于 2019-12-19 05:00:46

问题


I use Kafka streams to process real-time data, in the Kafka streams tasks, I need to access MySQL to query data, and need to call another restful service.

All the operations are synchronous.

I'm afraid the sync call will reduce the process capability of the streams tasks.

Is this a good practice? or Is there any good idea to do this?


回答1:


A better way to do it would be to stream your MySQL table(s) into Kafka, and access the data there. This has the advantage of decoupling your streams app from the MySQL database. If you moved away from MySQL in the future, so long as the data were still written to the Kafka topic from wherever it subsequently lived, your streams app would be unaffected. If it's just configurations you're storing in MySQL, you could even adopt the pattern that some people use of using Kafka as the primary store for data (using log compaction, to retain it forever).



来源:https://stackoverflow.com/questions/51948248/is-it-a-good-practice-to-do-sync-database-query-or-restful-call-in-kafka-streams

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!