I have one proxy endpoint, which needs to call the multiple target endpoints(Multiple Microservices).
Could you recommend, which is the best approach for calling multiple target endpoints.
Solved! Go to Solution.
@Mantesh Janagond , You can use Apigee Service Callout Policy. https://docs.apigee.com/api-platform/reference/policies/service-callout-policy
@Mantesh Janagond , Would you like to call them in series one after other / in parallel async ?
Thank you @Anil Sagar. I would like to call them in series one after other and First API response passed to next API so on.
@anilsr What if we need to call them in parallel, say we want to get responses from independent target services asynchronously?
Search here for "httpClient parallel" .
@Mantesh Janagond , You can use Apigee Service Callout Policy. https://docs.apigee.com/api-platform/reference/policies/service-callout-policy
Thank you so much @Anil Sagar,
We are planning to implement the following scenarios
Service 1 Request
-Service 2 Request
- Service 3 Request
- Service n Request
Case 1: Service 1 response data into service 2 request data and so on...
Case 2: Need only nth Service Response as the Proxy endpoint response
Case 3: Need an aggregation all services responses into Proxy endpoint response
Could you please provide the sample code for above scenarios?
Absolutely, You can do that in Apigee in matter of minutes. See example here. https://docs.apigee.com/api-platform/samples/cookbook/using-policy-composition
You can build that using https://docs.apigee.com/api-platform/reference/policies/service-callout-policy ,
Have you tried that ? Are you stuck at any point ?
-------------------------------
Anil Sagar
As mentioned below by Anil you can use servicecallout but if you use proxy chaining you can utilize inbuilt caching also
@munimanjunath kalapati How can I call multiple target proxies from single proxy using proxy chaining?
I know how to call single proxy but I need to call multiple target proxies using proxy chaining.
Please use ServiceCallout policy once for aggregation use a javascript policy and aggregate your response. I made max 8 servicecallouts in a proxy without any issue working fine in prod.
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |