Search code examples
spring-bootapache-kafkaproducer-consumer

Process all messages before posting result


I am doing a kaafka assignment and the task is to generate random messages by players for given seasons/rounds/game.

There is a consumer which listens to all these messages and will keep track of the scoring logic. Once the scoring is done, it will publish the score to a final topic.

Now the question i am getting confuse at is how does my score calculator would know that ALL scores from players have been received before publishing the final score?


Solution

  • That's the fun of unbounded data…it's unbounded :-) That is, there is not really the concept of "all data" having been received.

    You'd need to build some kind of logic into your application that either decides after a certain amount of time with no more data it is complete, or the application that emits the data sends some kind of "end of feed" message/watermark to indicate that what has been read by the consumer can be processed.