Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Target Endpoint/Server callout

Not applicable

I need to make a callout to Target Endpoint or Target Server in one of my flows and apply load balancing rules. Is there a way to do this using javascript or any other policy?

Solved Solved
2 10 5,358
1 ACCEPTED SOLUTION

Hi @MSaichuk

Welcome to Apigee Community !!!

Please refer to the Service Callout policy for example:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="service-callout">
    <DisplayName>service-callout</DisplayName>
    <Properties/>
    <Request clearPayload="true" variable="myRequest">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    </Request>
    <Response>myResponse</Response>
    <HTTPTargetConnection>
        <LoadBalancer>
            <Algorithm>RoundRobin</Algorithm>
            <Server name="httpbin"/>
            <Server name="yahoo"/>
        </LoadBalancer>
        <Path>/get</Path>
    </HTTPTargetConnection>
</ServiceCallout>

If you don't want to use Service Callout as mentioned above, you can achieve the same thing by defining a separate TargetEndpoint for that flow. Within the proxy endpoint, you can create a Route Rule to call that TargetEndpoint

<!-- Route rule for other target -->
<RouteRule name="second-target-endpoint">
    <Condition>(proxy.pathsuffix MatchesPath "/other")</Condition> <!-- /other is just an example here -->
    <TargetEndpoint>second-target-endpoint</TargetEndpoint>
</RouteRule>

<!-- Default -->
<RouteRule name="default">
    <TargetEndpoint>default</TargetEndpoint>
</RouteRule>

NOTE: Make sure the default route rule is placed at the end in the proxy end point

2835-screen-shot-2016-06-01-at-94435-am.png

And inside the second-target-endpoint configuration, you can use the Target Servers configured with load balancer

<HTTPTargetConnection>
        <LoadBalancer>
            <Algorithm>RoundRobin</Algorithm>
            <Server name="Target1"/>
            <Server name="Target2"/>
        </LoadBalancer>
    </HTTPTargetConnection>

Hope this helps ! Please reach out if you still have any questions.

View solution in original post

10 REPLIES 10