I am developing a Java application with Apache Camel and Spring. One step of the Camel flow is an asynchronous process that (among other things) updates state in a database. For consistency reasons, it is crucial that messages sharing specific traits are processed sequentially rather than parallel.
You can think of this as a kind of auctioning system bids for the same auction have to be processed sequentially, but bids from other auctions can be processed in parallel without a problem. In constrast to an auctioning system, it is not strictly necessary (though required) that messages are processed in order.
This part of the application is currently single-threaded in an otherwise mainly non-blocking application and (even though the tasks are usually short lived) might become a bottleneck in the future.
I was thinking of creating some kind of partitioned thread pool by using a hash of the trait (auction) as partitioning key, but I'm lost on how to implement this as I've just used thread pools and executor services so far. I'm also not sure if there are better ways to implement this requirement or if there are already libraries implementing a solution like this that can be integrated with Apache Camel and Spring (as changing the whole architecture is not an option). Unfortunately, my research so far did not succeed (maybe due to the lack of correct keywords).
Are there existing Java libraries that implement this kind of feature?
Aucun commentaire:
Enregistrer un commentaire