I have the following scenario :
For a given request, we call a function with 2 different sets of parameters. The results from these functions are aggregated and sent as a Map. Function that is called returns a CompletableFuture. Function issues maximum of 4 Async (Listenable Future) cassandra queries. The result from the queries are processed in the order in which they are issued. Based on some conditions the function could return after processing the response from the first query or process all the responses to get the desired result.
Function
@Async
public Map<String,Price> getPricing(String assetType,String code) {
//Issue Query 1 - Returns ListenableFuture
//Issue Query 2
//Issue Query 3
//Issue Query 4
Query 1 result satisfies return , else continue to Query 2 , followed by 3 and 4.
}
Service
public Map<String,Price> getPrice(String assetType) {
CompletableFuture<Map<String,Price>> a = .getPrice(assetType,"A");
CompletableFuture<Map<String,Price>> b = .getPrice(assetType,"B");
//Join A and B and return the result
}
Is this a better candidate for Spring Webflux + Reactive Spring data cassandra ? What would be the implementation approach ?