We need an interim solution to convert an Async process to a sync process. Trying to understand if it can be done via APIGEE.
In the current Async process here are the high-level steps.
1. client X sends request to proxy AP1 which forwards to target T1.
2. Target T1 sends the request to PROXY AP2 which forwards to backend target T2
-AND target T1 also returns a default response(R1) to proxy AP1
-Proxy AP1 returns the response R1 to client X. --- SO THIS COMPLETES ASYNC REQUEST FROM CLIENT X
3.Then target T2 makes a request by calling proxy AP3 which forwards to target endpoint T3. -- THIS IS THE ASYNC RESPONSE.
NOTE: CLIENT X will retrieve this response independently (does not wait for a response) and the cycle completes.
To make this Sync using APIGEE - the idea is :
1 Client X sends a SYNC request to proxy AP1 which forwards to target T1.
2. Target T1 forwards the request to proxy AP2 also as a SYNC request.
3. Now proxy AP2 needs to forward request to backend target T2 and wait. Can this be done with a waitForComplete()??
( ?? not sure if this will work - since we want it to wait for the response call to come in not for the current request to complete?? )
Any alternative?
Couple of things to NOTE here:
-Target T1 does not return the default response to AP1, as in the async process.
so T1 is waiting for the response and so are AP1 and client X.
-Request payload includes a unique ID (like a transactionID) that we're hoping to use
matchup with response.
4. Target T2 makes a request (this is the async response) by calling proxy AP3. and includes the unique transactionId from payload in AP2.
5. proxy AP3 will forward the request to proxy AP2.
6. proxy AP2 will
have conditional flow to check if this is coming from AP3 ( ??could check http header user-agent)
check the transactionId from payload- match with transactionId from waiting request ( ??how to do this if there are multiple waiting requests??)
extract the response ( R1) from AP3
set R1 as response to waiting request from AP2
7. Proxy AP2 will now send response R1 to waiting request from target T1
8. Target T1 will send response R1 to waiting request from proxy AP1
9. proxy AP1 will send response R1 to waiting request from client X.
I know it sounds convoluted, but this would be a interim solution until a longer term one can be rolled out.
Hope this makes sense. Is this even possible? TIA for your thoughts and suggestions.