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

后端 未结 1 1596
执念已碎
执念已碎 2021-01-07 11:18

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 op

1条回答
  •  南方客
    南方客 (楼主)
    2021-01-07 11:34

    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).

    0 讨论(0)
提交回复
热议问题