I have similar code like this answer. But now the question is when to start the listener programmatically, once the spring app starts. Should I write an event listener for an application event or are there more preferable ways?
You can either use an ApplicationListener
or implement SmartLifecycle
and start the containers in the start()
method.