I am having few endpoints in spring controller, who do the job of updating the event related data on the basis of eventId.
@PostMapping
public void updateNameOfEvent(String eventBody){
// fetch the eventId from the eventBody
// update the name of event in database and return the success response
}
@PostMapping
public void updateDetailsOfEvent(String eventBody){
// fetch the eventId from the eventBody
// update the details of event in database and return the success response
}
There could be a lots of eventId for which we can get the updates, but the sequence is affects a lot here, because whatever updates will come those will be in sequence order.
what I can do in order to achieve concurrency with sequential execution of events ?
what I can think of is as below, but need some suggestions on the same, if it's correct.
- Can create the multiple threads and divert the request on a basis of eventId hashkey. i.e. hash value with x amount will be forwarded to Thread A, and same goes to others eventId hashkey.(so here I will create the threads with the help of ThreadExecutor)
- Spring channel through which can create multiple channels and divert the request on basis of hash value of eventId.
So is Idea which I am proposing would be fruitful ? Also do I have any better and simpler approach apart from the above one ?