Asynchronous calls using service callout policy

I am using a service callout policy in a sharedflow, attached as a flowhook to my APIs, and do not have a <Response> entity in my policy. According to docs https://cloud.google.com/apigee/docs/api-platform/reference/policies/service-callout-policy#response... I expect the call to be async, but it is sync. In my debug session, I can see the trace and see that the service callout policy is taking time. 

Here is my service callout policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout continueOnError="true" enabled="true" name="ServiceCallout1">
<DisplayName>ServiceCallout1</DisplayName>
<Properties/>
<Request clearPayload="true" variable="Request1">
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</Request>
<HTTPTargetConnection>
<Properties/>
<URL>http://{host_ip}/path</URL>
</HTTPTargetConnection>
</ServiceCallout>

Any pointers on what I am missing or how to make async calls using Service Callout policy will help. Thanks. 

0 3 423
3 REPLIES 3

The servicecallout REQUEST is performed synchronously.  The policy does not wait for a response - that is the "asynchronous" part. 

According to what you describe, the policy is working as intended. If you need an asynchronous REQUEST, then you might want to try sending it to a local passthrough proxy, which then connects to your upstream. The local proxy will receive the request more quickly, and thereby allow your ServiceCallout to return more quickly. 

 

@dchiesa1, I am facing a similar issue. In my case I am calling another Apigee proxy(passthrough to a backend I am trying to connect to) using service callout with LocalTargetConnection (without response tag), but still the call is happening synchronously and I am able to see considerable time(1-2s) consumed by this service callout in the trace. PFB, the service callout configuration:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout name="Test">
    <DisplayName>Test</DisplayName>
    <Properties/>
    <Request variable="req">
        <Set>
            <Verb>GET</Verb>
            <Path>/apipath/name</Path>
        </Set>
        <Add>
            <Headers>
                <Header name="key">{key}</Header>
            </Headers>
        </Add>
    </Request>
    <LocalTargetConnection>
        <APIProxy>test-proxy</APIProxy>
        <ProxyEndpoint>default</ProxyEndpoint>
    </LocalTargetConnection>
</ServiceCallout>

 Anything I'm missing in the above?

I'm sorry you're having this problem. You're doing it right.

Something I learned recently is there's been a regression in the way ServiceCallout works. There is an entry in the public issue tracker for this. issues/280665967