Description
In what version(s) of Spring for Apache Kafka are you seeing this issue?
3.1.0 - though probably all as the main branch appears to be using SmartInitializingSingleton
Describe the bug
If I use @PostConstruct, and my bean depends on a NewTopic, and I've also created a KafkaAdmin bean, the topic is not automatically created.
I suspect the problem is the use of the SmartInitializingSingleton. It only runs after all beans have finished being initialized, and @PostConstruct methods have ran.
The workaround was to use a event listern on a context refreshed event, but I'm uncertain if that guarantees it's done before any business logic runs. I have to verify. But, the key point is that I've never encountered a problem like this with spring, it's very unexpected. At the very least, in the documentation for how topics are automatically created, it should state that it doesn't work with @PostConstruct.
To Reproduce
Use @PostConstruct, and depend on your NewTopic bean. You'll get a failure about the topic not existing.
Expected behavior
I was expecting, that because I depended on the NewTopic, it would be created, according to the documentation. This is true, that works, but not if my bean uses @PostConstruct
Sample
I don't have one, but I suspect it's easy enough for devs to replicate. If not, I can try and find the time to create one.