I have a working code for kafkalistener to read messages from the beginning(offset=0)
of a topic (always running).
For my use case (messaging) I need 2 things:
always catch new messages(this consumer is always running) of specific topic/partition and send to frontend websocket+stomp. (I already have this part)
start new consumer to get messages from beginning to current of specific topic/partition, only when frontend signals and then stop after that so that these data(loading previous messages for the late user or for later) can be fetched by frontend websocket+stomp (at the beginning of its session)
If I can dynamically (after getting signal from frontend) add/remove kafkaListener with parameters(data from post method) it will serve both
actually, how can I implement this? should I think of using post method to notify backend that I need to load previous messages of this topic/partition right now and send those it to this ".." url? but then how can I dynamically start and off that consumer(kafkaListener) without running all the time and pass parameter there?