I have a requirement, where my springboot service is reading data from Kafka topic called k1,k2,k3,k4 and k5.
spring boot service have it’s own internal cache, which is getting filled by consuming the data from topic k1, k2 and k3.
now whichever data received from k4 and k5, it will be get processed with the help of cache data which is fulfilled by data consumed from topic k1,k2,k3.
now here the special addition of requirement is, since in order to process message from k4 and k5 we need cache data processed from k1,k2,k3 so on service start, I don’t want to consume data from all the topics at the same time.
before service start, it should read the data from k1,k2 and k3 first, loads the cache then start listening from k4 and k5.but I am unable to find any optimized way to achieve this in springboot.
can we have any better way to implement ?
I tried using introducing the kafka consumer in postconstruct block, but I am unable to come out that block since it doesn’t know when to come out from that block ?