问题
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