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! Go to 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
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.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |