#How to listen for two separate get requests to return data
1 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @round gale! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
In the modern world, it is assumed that you want to run a kubernetes swarm, and these two requests of yours are likely to end up on two different servers.
So to link them both you're supposed to back them to a common data holder component between these two servers. Like a database or a distributed cache.
Anytime a server receives one such request, it would query the common data to check whether the other part is there. If so, it completes the operation. If not, it stores the part it just received.
That's the general viewpoint of the technologies you're using. You can follow them to the letter or adapt to it any way you see fit
Thanks for your response. My question is in regards to an Android app (I know there is Discord for Android, but Java questions aren't usually answered). There is no common data between the two lists. Is the Java-help chat just for backend or web projects? Apologies if it is.
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
That's not it, sorry, the way you describe your problem it looked like you were on the server side
Normally you should have a common state data structure that you save the result into, and when both results are obtained, you do what comes next.
But I don't know the specifics of Android
Got it, thanks for clarifying.
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Are the async operations each returning a ListenableFuture? If so, you could consider using allAsList from Guava https://guava.dev/releases/snapshot/api/docs/com/google/common/util/concurrent/Futures.html#allAsList(com.google.common.util.concurrent.ListenableFuture...) - it basically gives you a single ListenableFuture that will have the values of both your async queries when they both complete
the android docs mention it here https://developer.android.com/guide/background/asynchronous/listenablefuture