Reputation: 33
I have the following scenario.
The issue is that I want to block on the original user's request for information until I get the information back via the callback. I'm not sure how I should code that it in java. I'm using spring boot (though I'm not sure how relevant that is). I'm also looking at coding that either as a normal spring boot mvc app or a reactive spring boot app (I'd like to do the latter, but I'm still learning about reactive spring boot). Regardless, I'd be interested in solutions for either framework.
The basic question is how do I block on the initial user information request until the third party site sends the information to the callback url? I've looked at futures and promises and either I don't really understand them or they aren't the droids I'm looking for.
Any suggestions? Thanks in advance.
Upvotes: 0
Views: 895
Reputation: 13535
If you want to block a thread while waiting the reply from third party, this is useless wasting of resources. You need to prepare an object with all the information about the user's request and assign a uniqe id to it, and to send request to the third party with callback url containing that id, like http://myservice.org/callback?id=123
. Start a server to accept that callbacks. That server extracts id from url, finds the user request object with this id from hashmap, and sends the reply.
Upvotes: 1