I have a Kafka consumer written in springboot application, which consumes the payload from Kafka topic called matchupdates, process it and save it to database. Since I am having huge updates receiving for the match, respective payload can be identified using the matchId.
consider following are the payloads which springboot service consumes, where M1,M2 are nothing but the matchId, and respective updates denotes the fields.
M1 -> (update1) {matchid,name,....}
M1 -> (update2) {matchid,name,....}
M1 -> (update3) {matchid,name,....}
M2 -> (update1) {matchid,name,....}
M2 -> (update2) {matchid,name,....}
Here my requirement is,** identical payloads should be consumed sequentially only** (i.e. update1,update2, update3 of the matchId M1 should be processed sequentially(i.e. processing, and updates in database, and** if any operation taking longer in execution then rest of the updates should wait in the queue**) whereas, update1 of M1 and update2 of M2 can be processed parallelly.
Can I achieve this using service executors or any other way in Java through which I can processes identical payloads sequentially only and if required they need to be wait in Queue until ahead updates are not processing.
I tried using threadpool executor with the Queue, but every time it is assigning to different thread available in the pool, which causes to payloads getting executed parallelly with the identical MatchId.