How to load a compacted topic in memory before starting the context

非 Y 不嫁゛ 提交于 2019-12-10 12:16:13

问题


I'm using a compacted topic in kafka which I load into a HashMap at the application startup. Then I'm listening to a normal topic for messages, and processing them using the HashMap constructed from the compacted topic.

How can I make sure the compacted topic is fully read and the HashMap fully initialized before starting to listen to the other topics ? (Same for RestControllers)


回答1:


Implement SmartLifecycle and load the map in start(). Make sure the phase is earlier than any other object that needs the map.



来源:https://stackoverflow.com/questions/56017730/how-to-load-a-compacted-topic-in-memory-before-starting-the-context

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