According to the docs "when service callout policy <Response> tag is omitted, the API proxy does not wait for the response and continues with the subsequent steps", thus making it an asynchronous call.
To test this I created two API proxies. One to mock(say mock API) a backend service(That takes about 30 seconds to respond) and the other(say client API) to call this API using service callout policy. Below is my service callout policy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ServiceCallout async="false" continueOnError="false" enabled="true" name="SC-CallMocky"> <DisplayName>SC-CallMocky</DisplayName> <Properties/> <Request> <Set> <Verb>GET</Verb> </Set> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> </Request> <Response>calloutResponse</Response> <!--to be removed to make it an async call--> <HTTPTargetConnection> <Properties> <Property name="success.codes">2xx,4xx,5xx</Property> <Property name="connect.timeout.millis">120000</Property> <Property name="io.timeout.millis">120000</Property> </Properties> <URL>https://xxxxxxxx-xxxx-test.apigee.net/mocky/slowpoke</URL> </HTTPTargetConnection> </ServiceCallout>
When the <Response> tag is retained I can see the flow works as expected - I can see the trace in the mock API and also the client API takes ~30s to respond.
But when I remove the <Response> tag, the client API responds in about a second but I do not see a trace in the mock API(meaning the mock API was never invoked?).
I understand async calls can be made using JS policy. I wanted to check if this is possible using service callout policy.
The question I've got is, is my understanding about using service callout policy for async calls correct? If yes any pointers as to why my approach to test this isn't working would be really helpful.
Thank you.
Solved! Go to Solution.
I've tested your scenario and reproduced it here.
When using a ServiceCallout to invoke another Apigee Edge API Proxy in the same org/env, with HTTPTargetConnection and fire-and-forget (no Response configured in the ServiceCallout), what I observe is: the service callout does not always send the outbound request. This seems like a bug.
ref: b/110535186
This can be avoided if you use LocalTarget:
<ServiceCallout name='SC-TargetDelay-Asynch'> <Request variable='simpleGetRequest'> <Set> <Verb>GET</Verb> </Set> </Request> <!-- exclude Response to make this call async --> <!-- <Response>tokenResponse</Response> --> <LocalTargetConnection> <Path>/passthrough1/whatever</Path> </LocalTargetConnection> <!-- <HTTPTargetConnection> <SSLInfo> <Enabled>true</Enabled> <IgnoreValidationErrors>false</IgnoreValidationErrors> </SSLInfo> <Properties> <Property name='success.codes'>2xx</Property> </Properties> <URL>https://MYORG-MYENV.apigee.net/passthrough1</URL> </HTTPTargetConnection> --> </ServiceCallout>
I've filed a bug (b/110535186). Because the problem only affects one proxy calling another, and because there is an easy workaround it will be rated at P3.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |